Offseting the center of the MapFragment for an animation moving both the target lat/lng and the zoom level

The most recent version of the play services library adds a setPadding() function to GoogleMap. This padding will project all camera movements to the offset map center. This doc further explains how map padding behaves. The question originally asked here can now simply be solved by adding left padding equivalent to the width of the … Read more

Error opening SupportMapFragment for second time

Update: As an alternative solution (which I think is much better) you can use a MapView which is described: here I ran across a similar problem while working with a tabs implementation. With Google Maps V2, you are stuck with the SupportMapFragment, so using the MapView isn’t an option. Between juanmeanwhile’s post and comment #1 … Read more

Moving MapFragment (SurfaceView) causes black background flickering

Of course the proper solution will be for Google to fix the problem (see Android Maps V2 issue 4639: http://code.google.com/p/gmaps-api-issues/issues/detail?id=4639). However, one of my coworkers suggested simply extending the map beyond its container. If we extend the map fragment beyond the visible region of its container, like so: android:layout_marginLeft=”-40dp” android:layout_marginRight=”-40dp” we can reduce/eliminate the flickering. … Read more

Set Image from drawable as marker in Google Map version 2

This is how you can set a Drawable as a Marker. BitmapDescriptor icon = BitmapDescriptorFactory.fromResource(R.drawable.current_position_tennis_ball) MarkerOptions markerOptions = new MarkerOptions().position(latLng) .title(“Current Location”) .snippet(“Thinking of finding some thing…”) .icon(icon); mMarker = googleMap.addMarker(markerOptions); VectorDrawables and XML based Drawables do not work with this.

Change position of Google Maps API’s “My location” button

You can get the “My Location” button and move it, like : public class MapFragment extends SupportMapFragment { @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View mapView = super.onCreateView(inflater, container, savedInstanceState); // Get the button view View locationButton = ((View) mapView.findViewById(1).getParent()).findViewById(2); // and next place it, for exemple, on bottom right (as … Read more

GoogleService failed to initialize

[From Product Manager @ Google] You can fix this issue by downloading and copying the google-services.json file for your Android app by following the steps below: Select your app/project name and Android packagename from this link and click Continue to Choose and configure services. Click Continue to Generate Configuration files. Download google-services.json and copy the … Read more