Reputation: 655
This is my code to display markers, of varying colors dictated by custom function analyzeSampleDataToMarkerColor()
, on the google maps from a thread as the data resides in the cloud. The markers don't appear at first but works after subsequent refresh. Any reason? Should I allocate variable marker
before the assignment? Or should the function be implemented in the UI thread ?
for (int i = 0; i < stations.size(); i++) {
LatLng pos = new LatLng(stations.get(i).getLatitude(), stations.get(i).getLongitude());
MarkerOptions markerOptions = new MarkerOptions()
.position(pos)
.icon(BitmapDescriptorFactory.defaultMarker(analyzeSampleDataToMarkerColor(stations.get(i))));
Marker marker = mMap.addMarker(markerOptions); // memory allotment of marker require before this assignment?
}
Upvotes: 0
Views: 41
Reputation: 5166
Call showInfoWindow()
in your loop to display the markers like so:
Marker marker = mMap.addMarker(markerOptions);
marker.showInfoWindow();
Upvotes: 1