I am showing a Google Map in my Android Activity which extends FragmentActivity. The map is loaded from the xml layout as follows:
<fragment
android:id="@+id/map"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/ad_layout"
class="com.google.android.gms.maps.SupportMapFragment" />
The user can perform certain functions on the map only if the map tiles have finished downloading. Is there a way to determine if the map tiles have finished downloading and are visible - besides obviously looking at the map?
Set an onCameraChangeListener this will be fired off when the map has finished loading. Do whatever you wish to do then remove the listener so that it only happens once.
map.setOnCameraChangeListener(new OnCameraChangeListener() {
@Override
public void onCameraChange(CameraPosition arg0) {
//TODO: move camera, do whatever you need to do etc...
// remove listener so that position is not reset when user touches map
map.setOnCameraChangeListener(null);
}
});
Add OnMapLoadedCallback Listener to your google map object in your activity/fragment
googleMap.setOnMapLoadedCallback(new GoogleMap.OnMapLoadedCallback() {
@Override
public void onMapLoaded() {
// perform certain functions();
}
});
For More Reference: https://developers.google.com/android/reference/com/google/android/gms/maps/GoogleMap.OnMapLoadedCallback
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