Creating popups with data from a feature data service

4161
1
07-18-2014 08:45 AM
Labels (1)
joepublic
New Contributor III

I am using esri-leaflet to visualize some data via an esri feature data service.

When I click on the map I get the error shown below:

 

TypeError: Argument 1 of Node.appendChild does not implement interface Node.

 

My spec:

 

var countries = new L.esri.FeatureLayer(featureURL, {

  style: function () {

  return {color: "#70ca49", weight: 2,  fillOpacity: 0.3};

  }

 

var popupTemplate = "<h3>{CNTRY_NAME}</h3>";

 

countries.bindPopup(function(feature){

  return L.Util.template(popupTemplate, feature.properties)

  });

 

Any idea as to what I am doing wrong?

0 Kudos
1 Reply
WinstonHoyle
New Contributor II

You have some small syntax errors. 

var countries = new L.esri.featureLayer({
   url: featureURL,
   style: function () {
      return {
         color: "#70ca49",
         weight: 2,
         fillOpacity: 0.3
      }
   }
}).addTo(map);

var popupTemplate = "<h3>{CNTRY_NAME}</h3>";

countries.bindPopup(function (layer){
   return L.Util.template(popupTemplate, layer.feature.properties)
});‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Popups using Esri-Leaflet: https://esri.github.io/esri-leaflet/examples/feature-layer-popups.html

Popups using Leaflet: https://leafletjs.com/reference-1.3.2.html#popup