I am developing a GoogleMap based android application.
I need to display 1000's of Markers on the map.
Currently I retrieve the Latitude and Longitude for each marker from an SQLite database loader and add the markers in the public void onLoadFinished(final Loader loader, final Cursor cursor)
method.
this approach gives a very bad user experience though, as the application does not respond while i add the Markers.
how can i add 1000's of markers to a googlemap and keep my application responsive?
as i have to add the markers to the map on the main UI thread.
One possible way is to only add Marker
s when they fall into visible region of the map.
You would actually have to move your calls to addMarker
from onLoadFinished
to onCameraChange
and in onLoadFinished
only create a list of data needed to create these Marker
s. In the simplest form this might be List<MarkerOptions>
.
Android Maps Extensions mentioned by Lalit Poptani in the comments above can handle that for you even if you don't want to use clustering. You simply leave your code like it is and only make a call like
googleMap.setClustering(new ClusteringSettings().enabled(false).addMarkersDynamically(true));
after replacing Google Maps Android API v2 with this extensions lib.
setClustering
for GoogleMap
object. Is this not there in the new library? –
Haply You can use Spatial Lite provider with geoserver to provide WMS maps. In android you can set a tile provider to consuming such tile maps.
© 2022 - 2024 — McMap. All rights reserved.