ark1974
ark1974

Reputation: 655

Issue related to display of markers on Google Maps

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

Answers (1)

ObliteratedJillo
ObliteratedJillo

Reputation: 5166

Call showInfoWindow() in your loop to display the markers like so:

 Marker marker = mMap.addMarker(markerOptions);
 marker.showInfoWindow();

Upvotes: 1

Related Questions