I'm trying to set the user location on the map such that it sits about 1/3 of the way up from the bottom of the screen, and when the map rotates, it will rotate around this point.
The closest I've got to achieving this is by using the setPadding()
method, however, this causes the map to sort of shake when rotated, as the center point sort of 'floats' around where it actually should be. It looks quite ugly
int mapHeight = mapView.getHeight();
googleMap.setPadding(0, mapHeight / 5, 0, 0);
Is there a better way to do this?
Edit: Explained in picture below
Please go to your map and drag and drop your map to the position you wish. You can also zoom in your map a little bit with mouse wheel or zoom cotrols on the bottom right corner of the map. Please remember to save your map after any changes. Hope that helps.
Remove an incorrect or fraudulent listing Find the place you want to report for review. Close or remove. Choose the reason the place should be removed. Click Submit.
You don't need paddings
Change mappoint X and Y values as you need you can call this where you want! may be inside your onLocationChanged
like 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 as you need , just hard coded a value if you want you can give it based on a ratio like using DisplayMetrics as well
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(mGoogleMap.getProjection().fromScreenLocation(mappoint)));
}
output :
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With