I am building a leaflet map with feature layers that are hosted on ArcGIS online.
I would like to write a simple function so that when I click on a feature, the value of a particular column in the attribute table will be saved to a variable and logged to the console.
I have been able to get the value to appear in a pop-up, but not log to the console.
I have a feeling the solution has something to do with this, but I have limited experience with esri-leaflet so there is something I am missing:
https://esri.github.io/esri-leaflet/api-reference/tasks/identify-features.html
var map = L.map('map').setView([40.1562,-75.057104], 9);
L.esri.basemapLayer("Gray").addTo(map);
var trails = L.esri.featureLayer({
url: "https://services1.arcgis.com/Ps1YVQiv5JQLIFu2/arcgis/rest/services/CIRCUIT_TRAILS/FeatureServer/0",
style: function () {
return { color: "#70ca49", weight: 2 };
}
}).addTo(map);
var popupTemplate = "<h3>{CIRCUIT_ID}</h3>";
trails.bindPopup(function(e){
return L.Util.template(popupTemplate, e.feature.properties)
console.log(e.feature.properties.CIRCUIT_ID)
});