I have a displayed markers for the leaflet-knn on the map and the name of marker is displayed on the div at right-panel. When I click on this list, I want to show the popup on the associated marker. I have to pass selected text on right panel click but how can I show.
This is code so far I have tried.
HTML
<div class="container"> <div class="row"> <div id="map"></div> </div> <div class="right-panel"> <h3>Nearby Search Result</h3> <div id="results"> <div class="ui list"></div> </div> </div> </div> JS
var gjLayer = L.geoJson(testCities, { onEachFeature: onEachFeature }); function onEachFeature(feature, layer) { layer.on('click', function(e) { let feature = this.feature; let content = "<b>Name:</b> " + feature.properties.name; e.latlng.layer.bindPopup(content); }); } $(function() { let res; const distance = 10000; const longitude = myloc.lng; const latitude = myloc.lat; res = leafletKnn(gjLayer).nearest( [longitude, latitude], 5, distance); for (i = 0; i < res.length; i++) { var result = res[i].layer.feature.properties; map.addLayer(res[i].layer); searchResult(result); } function searchResult(result) { item = ''; item = '<div class="item">' + '<div class="content">' + '<a class="header">' + result.name + '</a></div></div>'; $(".ui.list").append(item); } $('.content').on('click', function(e) { let content = $(this).text(); onEachFeature(content); }) });