Change Offset
suggest changeAdjust the screen point's x and y before converting it back to a LatLng. By default the location sits at the center of the map view. Call this method wherever the center should move, for example from onLocationChanged: changeOffsetCenter(location.getLatitude(), location.getLongitude());
public void changeOffsetCenter(double latitude, double longitude) {
Point mappoint = mGoogleMap.getProjection().toScreenLocation(new LatLng(latitude, longitude));
// Move the target up by 100 px so the location sits below the center.
// Scale this offset from DisplayMetrics if it should track screen size.
mappoint.set(mappoint.x, mappoint.y - 100);
mGoogleMap.animateCamera(CameraUpdateFactory.newLatLng(
mGoogleMap.getProjection().fromScreenLocation(mappoint)));
}
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents