Search code examples
androidgoogle-mapsgoogle-maps-android-api-2google-maps-api-2

How to make the marker appear in the center of the Google Map initial window?


I am using Google Maps V2 Android in my app.

I place a marker at the point of Singapore.

But I notice every time my app starts up, the initial window is somewhat always South America.

How may I make the map automatically zoom to Singapore area with the marker in the center?

I place the marker as follows:

googleMapLocation = new LatLng(latitude, longitude);
map = ((MapFragment) getFragmentManager().findFragmentById(R.id.map)).getMap();
map.addMarker(new MarkerOptions().position(googleMapLocation).title("I am here!"));

Solution

  • You can use:

    map.moveCamera(CameraUpdateFactory.newLatLngZoom(googleMapLocation, zoom));