How do I set default location and Zoom level for google map api v2?

后端 未结 5 1999
予麋鹿
予麋鹿 2020-12-02 07:13

When my map shows, it always start at a fixed location (near Africa).

Then, I use the following code to center the map to the location I want.

mMap.a         


        
5条回答
  •  萌比男神i
    2020-12-02 07:31

    Take a look at the documentation here:

    https://developers.google.com/maps/documentation/android-api/map#configure_initial_state

    The way to do it is slightly different depending on whether you are adding the map via XML or programmatically. If you are using XML, you can do it as follows:

    
    

    If you are doing it programmatically, you can do the following:

    CameraPosition cameraPosition = new CameraPosition.Builder()
        .target(new LatLng(-33, 150))
        .zoom(13)
        .build();
    MapFragment.newInstance(new GoogleMapOptions()
        .camera(camera));
    

提交回复
热议问题