This question already has an answer here:
I have a basic google map on which I'm trying to add markers using the MarkerWithLabel extension. I have to load the coordinates from a json object, and on the label I have to put the sort order of the markers, which is also from the json.
The problem is that the custom icon I load for the markers only works on the last one and I can't figure out why. They all position correctly, but the other ones do not have an icon.
Here is the function I used to add the markers :
function CreateTourMarkers(json) {
if (json.length > 0) {
json.forEach(function (item) {
var myCoord = new google.maps.LatLng(item.Lat, item.Lng);
var marker = new MarkerWithLabel({
position: myCoord,
map: vehiclesMap,
icon: {
url: image
},
labelContent: item.SortOrder,
labelAnchor: new google.maps.Point(5, 37),
labelClass: "map-labels",
marker: MarkerWithLabel,
labelInBackground: false
});
});
}
}
Also here is a fiddle showing the problem : fiddle
Any help would be greatly appreciated.
Thanks
I updated your Fiddle to use the v1.1.9 of markerwithlabel.js and it shows the custom icon on all markers so I'm assuming it must be a bug with v1.1.8.