My question should be fairly straightforward.
If it helps to explain, I am currently using a javascript library called Leaflet. This library allows me to create a customizable online map that I can add markers to, which is what I am doing right here:
var iconId = null;
for (var i=1;i<4;i++)
{
iconId = "mapMarker" + i; // L.marker does not accept this because it is a string and not an object
var marker = L.marker([boulder.latitude, boulder.longitude], {icon: iconId}).addTo(map);
}
In another JS file, I have created 3 mapMarker objects with attributes compliant to Leaflet's documentation.
var mapMarker1 = L.icon({
iconUrl: 'img/mapMarker1.png'
});
var mapMarker2 = L.icon({
iconUrl: 'img/mapMarker1.png'
});
var mapMarker3 = L.icon({
iconUrl: 'img/mapMarker1.png'
});
As you can see, I currently have a loop that creates a string with the name of the object I want to pass into the icon parameter, but the icon parameter is expecting an object, and not a string. Is there a way I can dynamically create object names and put them in "iconId"? I do not want to put this into a switch case, as it would be too large for my taste.
Thanks!