I have markers on my map created by geoJson data that represent restaurants, bars, etc…. Each marker has 2 properties; 1)Name – name of the site, bar restaurant, etc… 2)Link-a link to the establishment's website. Currently, I have added a popup that displays the Name. My goal is to make the name based on into a hyperlink based on the link property that the user can click on and open corresponding the website. How could I best achieve this?
var layerGroup = L.geoJSON(data, {
onEachFeature: function (feature, layer) {
layer.bindPopup(feature.properties.Name +'<br>'+feature.properties.Link);
}
}).addTo(map);
My best guess would be something like this: layer.bindPopup("<a href='feature.properties.Link'>" + feature.properties.Name + "</a>")
Best Answer
Just pay attention to your quotes.