cordova-plugin-googlemaps icon indicating copy to clipboard operation
cordova-plugin-googlemaps copied to clipboard

Most marker's info window content is blank when creating many markers at once.

Open JeffreyJamesAttenti opened this issue 9 years ago • 1 comments

My app has a feature that loads multiple markers to show a history of locations that someone has visited. There is some time that it takes to render but I think that is well known for this plugin and possibly the native Google map SDKs but once everything is rendered, most of the markers have blank info windows.

I'm setting the info window content by setting the "title" marker option with a data URL that is an image. Is there a workaround/possible fix or is this some type of limitation? To give you an idea how many markers I'm dealing with, the app can create up to 1500 at one time.

JeffreyJamesAttenti avatar Jan 23 '17 20:01 JeffreyJamesAttenti

var positions = [
   {"position" : {lat: ...., lng: ...}, "title": "....", ....},
   {"position" : {lat: ...., lng: ...}, "title": "....", ....},
   {"position" : {lat: ...., lng: ...}, "title": "....", ....},
   {"position" : {lat: ...., lng: ...}, "title": "....", ....},
   {"position" : {lat: ...., lng: ...}, "title": "....", ....},
   {"position" : {lat: ...., lng: ...}, "title": "....", ....}
];
addMarkers(positions, function(markers) {
  //done
});

function addMarkers(positions, callback) {
  var markers = [];
  function onMarkerAdded(marker) {
    markers.push(marker);
    if (markers.length === data.length) {
      callback(markers);
    }
  }
  positions.forEach(function(markerOptions) {
    map.addMarker(markerOptions, onMarkerAdded);
  });
}

https://github.com/mapsplugin/cordova-plugin-googlemaps/wiki/Marker#create-multiple-markers

wf9a5m75 avatar Jan 23 '17 21:01 wf9a5m75