Reputation: 6286
I noticed a huge amount of lag when adding some (50) colored markers onto a google map. There are about 20 different hue colors the markers need to have. I tried storing the generated BitmapDescriptor
in a hashmap and from a background thread and retrieving it when adding the marker, which decreased the lag by about 10%. When I set no marker color and leave it on the default red, I get no lag at all.
How I add the markers:
googleMap.addMarker(new MarkerOptions()
.title(title)
.snippet(snippet)
.position(new LatLng(lat, lng))
.icon(BitmapDescriptorFactory.defaultMarker(hue)));
Is there anything I can do to prevent some of this lag, except using clustering, which will not work for me in this case.
Upvotes: 0
Views: 869
Reputation: 3456
This is a known issu, see #7174 for more informations.
To avoid this problem, you can use this directly (all the markers will be red in this case):
BitmapDescriptorFactory.defaultMarker()
Or the easiest way, use a custom markers :
BitmapDescriptorFactory.fromResource(R.drawable.custom_marker)
Upvotes: 1