The title is not the best explanation. I'm creating a beer flavour graph (no map tiles involved) that uses a custom icon of each beer bottle for each marker. So far so good.
screenshot of the current build
I've got a div outside the map, where I want to display the same bottle png used for the icon (but larger) when each marker is clicked...
for (var i=0; i < markers.length; ++i )
{
var IconVar = L.icon({
iconUrl: markers[i].bottleurl,
shadowUrl: 'images/beer-shadow.png',
iconSize: [36, 120],
shadowSize: [74, 50],
iconAnchor: [16, 60],
shadowAnchor: [35, -26],
popupAnchor: [0, -65]
})
var bigbottleUrl = markers[i].bottleurl;
L.marker( [markers[i].lat, markers[i].lng], {icon: IconVar}, )
.bindPopup( 'Text and some custom content bla bla', customOptions )
.on('click', function(e){document.getElementById("bigbottle").src = bigbottleUrl;}).addTo( beermap );
}
Which works to a point, but defaults to the last marker that is set from a json file. Maybe I can't call different variables from inside the loop, or I haven't set up my loop right.
I've looked through lots of questions here, and tried making it more specific using e.popup._source and this.option and making it specific using _leaflet_id but I'm pushing well beyond my understanding of javascript!
Any ideas?