AnsweredAssumed Answered

Display esri leaflet feature's popup on open

Question asked by wjackson_ArkansasDEQ on Sep 7, 2018
Latest reply on Sep 7, 2018 by JGravois-esristaff

I've recently started exploring leaflet and have tried tweaking a few simple examples I've found. I would like to be able to query a feature service of points, zoom to feature(s), and then display a popup with attribute information by default for each feature. I would also like to be able to click on a feature to open a popup. The attached code does not display a map but I've had bits and pieces working so I think it's almost there. Any assistance much appreciated.


  <meta charset=utf-8 />
  <title>Load each and every feature initially</title>
  <meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' />

    <!-- Load Leaflet from CDN -->
    <link rel="stylesheet" href=""
    <script src=""

    <!-- Load Esri Leaflet from CDN -->
    <script src=""

    body { margin:0; padding:0; }
    #map { position: absolute; top:0; bottom:0; right:0; left:0; }

<div id="map"></div>


  var map ="map").setView([45.5666, -122.6921], 18);


  var url:'';
  var variable = "Black Walnut"

  // query a feature service for a tree species

  var pointQuery = L.esri.query({
    url: url
  }).where("COMMON_NAM =" + "'" + variable + "'").run(function(error, trees){
     treesMatch = L.geoJSON(trees,

     onEachFeature: function (feature, layer)
                    var popupAuto = L.popup({ offset: L.point([1,-30])}) 
                    setLatLng([layer.geometry.coordinates[1], layer.geometry.coordinates[0]])
                    .setContent('Name = ' +
                    var popupClick = layer.bindPopup('Name = ' +;