My question is I have a variable called 'url' and I want it to show up in the popup. However, this is not working <a href = feature.properties.url >Website</a>
. Also this leaflet code is integrated with rChart
. My original codes are as below:
map$geoJson(toGeoJSON(df2_sub_list, lat = 'venue_lat', lon = 'venue_lng'),
onEachFeature = '#! function(feature, layer){
layer.bindPopup(feature.properties.venue_name + \'</br><a href =
feature.properties.url> Website </a>\')
} !#',
pointToLayer = "#! function(feature, latlng){
return L.circleMarker(latlng, {
radius: 4,
fillColor: feature.properties.colors || 'red',
color: '#000',
weight: 1,
fillOpacity: 0.8
})
} !#"
You're not concatenating your HTML string and variable properly and using spaces in your attribute assignment:
feature.properties.venue_name + \'</br><a href = feature.properties.url> Website </a>\'
Should be:
feature.properties.venue_name + \'</br><a href=\' + feature.properties.url + \'> Website </a>\'
Also, you're not quoting your attribute value but that shouldn't be a problem if you're using HTML5.