android - Change Google Map Offset Center -
i'm trying set user location on map such sits 1/3 of way bottom of screen, , when map rotates, rotate around point.
the closest i've got achieving using setpadding()
method, however, causes map sort of shake when rotated, center point sort of 'floats' around should be. looks quite ugly
int mapheight = mapview.getheight(); googlemap.setpadding(0, mapheight / 5, 0, 0);
is there better way this?
edit: explained in picture below
you don't need paddings
change mappoint x , y values need can call want! may inside onlocationchanged
changeoffsetcenter(location.getlatitude(),location.getlongitude());
public void changeoffsetcenter(double latitude,double longitude) { point mappoint = mgooglemap.getprojection().toscreenlocation(new latlng(latitude, longitude)); mappoint.set(mappoint.x, mappoint.y-100); // change these values need , hard coded value if want can give based on ratio using displaymetrics mgooglemap.animatecamera(cameraupdatefactory.newlatlng(mgooglemap.getprojection().fromscreenlocation(mappoint))); }
output :
Comments
Post a Comment