Using MapQuest, I want to create a flag with the same colour/size options, but different texts (symbol option) for different locations.
In the js function I have:
var iconA = L.mapquest.icons.flag( {
primaryColor: '#2240fF',
secondaryColor: '#ff5998',
shadow: true,
size: 'sm',
symbol: 'K1'
}) ;
I want to be able to override symbol
with 'K2', 'K3' etc, but keep the other marker options.
What I would like to do is to create a loop as follows (assuming the data
object has been correctly instantiated):
for ( i = 0; i <= data.length; i++ ) {
var iconI = iconA.include({ symbol: 'K' + i });
L.marker([ data[i].lng, data[i].lat ], {icon: iconI} ).addTo(map);
}
This does not seem to work, even though that seems to be what the Leaflet documentation on extending classes implies.
A way that works is:
for ( i = 0; i <= data.length; i++ ) {
var iconI = L.mapquest.icons.flag( {
primaryColor: '#2240fF',
secondaryColor: '#ff5998',
shadow: true,
size: 'sm',
symbol: 'K' + i
});
L.marker([ data[i].lng, data[i].lat ], {icon: iconI} ).addTo(map);
}