Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Location Center of Map - GMaps v2 - Android

How do I set the center of the map to a specific location using GMaps v2? This is how I did it using GMaps v1:

public void setCenter( LatLng point )
{
  if( point.latitude*1000000 != 0 && point.longitude*1000000 != 0 )
  {
     if( mMapController != null )
     {
        mMapController.setCenter( point );
     }
     /*else if( mOpenStreetMapViewControllerSource != null )
     {
        mOpenStreetMapViewControllerSource.getController().setCenter( new org.osmdroid.util.GeoPoint( point.getLatitudeE6(), point.getLongitudeE6() ) );
        mPostponedSetCenterPoint = point;
     }*/
  }
}

I have looked through the API for GMaps v2 and can't find and similar functionality. How do I do this?

like image 744
user268397 Avatar asked May 02 '13 15:05

user268397


1 Answers

You can try:

map.moveCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(latitude, longitude), zoom));

where map is the GoogleMap instance.

like image 116
Brtle Avatar answered Nov 15 '22 22:11

Brtle