I have an Android application that can add 1000's of markers to an Extended GoogleMap using Android Maps Extensions. However i would like to use
requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
while the markers are being added to the map which takes 2 - 5 seconds. My problems are:
- I have to add the 1000's markers on the UI thread.
- The indeterminate spinner is also running on the UI thread so it "sticks" while the map markers are being added.
How do i run the indeterminate spinner in its own thread so it isn't affected by the 1000's of markers being added to the Extended map? The extended map settings i am using are these:
final FragmentManager fm = getSupportFragmentManager();
final SupportMapFragment f = (SupportMapFragment) fm.findFragmentById(R.id.map);
mGoogleMap = f.getExtendedMap();
final ClusteringSettings settings = new ClusteringSettings();
settings.iconDataProvider(new TowerIconDataProvider(getResources()));
settings.addMarkersDynamically(true);
mGoogleMap.setClustering(settings);
UPDATE
I discovered the root cause of my addMarker()
performance issue; every timer i added a marker to my GoogleMap i was calling
.icon(BitmapDescriptorFactory.fromResource(R.drawable.my_drawable))
to customise the marker icon
Once I amended my code to perform this outside my addMarker loop, i achieved the desired response time.
Thanks to MaciejGórski for pushing me to really look at my own code.