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.animateCamera(CameraUpdateFactory.newLatLngZoom(new LatLng(loc.getLatitude(), loc.getLongitude()), 14.0f));
My question is that could I set a default location and zoom level before the map shows?
Because I don't want my users to see the animation at the beginning.
Thanks.
You can change the zoom level of the map using simple steps. Step 1 Go to Add or Edit Map page . Step 2 Select 'Default zoom level' in the 'Map Information section'. Step 3 click save map and see the changes.
Users can zoom the map by clicking the zoom controls. They can also zoom and pan by using two-finger movements on the map for touchscreen devices.
Setting up the minimum or maximum Zoom value for Google Maps can be done by adding the shortcode attribute with Store Locator Shortcode. Furthermore, the maximum value of Google Maps Zoom level is 22. Therefore, the defined maximum value must be below or equal to 22, which is the default.
To fix Google maps zooming problems, for Google maps default zoom you want to know how to change the zoom level on Google Maps. You can change the zoom level by going to the Edit map page and then selecting 'default zoom level' in the map information section and then clicking save map.
you can use this to zoom directly without the animation :
map.moveCamera( CameraUpdateFactory.newLatLngZoom(new LatLng(xxxx,xxxx) , 14.0f) );
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:
<fragment xmlns:android="http://schemas.android.com/apk/res/android" xmlns:map="http://schemas.android.com/apk/res-auto" android:id="@+id/map" android:layout_width="match_parent" android:layout_height="match_parent" class="com.google.android.gms.maps.SupportMapFragment" map:cameraBearing="112.5" map:cameraTargetLat="-33.796923" map:cameraTargetLng="150.922433" map:cameraTilt="30" map:cameraZoom="13"/>
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));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With