I have some external HTML (that is generated from GeoJSON) that has a list of markers that on the map. An example of an item is:
<ul id="marker-list">
<li data-lat="53.3895673" data-lng="-1.4725166">Marker 1</li>
</ul>
Then I have the following jQuery that listens for a click event on one of the items and should then focus on those coordinates and trigger the click event on the marker (to open its popup).
$(document).on('click', '#marker-list li', function(e){
e.preventDefault();
var latlngPoint = new L.latLng($(this).attr('data-lat'), $(this).attr('data-lng'));
map.setView(latlngPoint, 18);
map.fireEvent('click', {
latlng: latlngPoint,
layerPoint: map.latLngToLayerPoint(latlngPoint),
containerPoint: map.latLngToContainerPoint(latlngPoint)
});
});
The setView works fine but the popup isn't being opened...
Adding:
map.on('click', function(e){
console.log(e);
});
Reveals that the click event is being fired, but it doesn't cause the popup to open... How can I get the popup to open? Is there a way to target the marker instead?