<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Display esri leaflet feature's popup on open in Open Source Mapping Libraries Ques.</title>
    <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/display-esri-leaflet-feature-s-popup-on-open/m-p/790141#M178</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you have a bunch of different things going on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;&lt;SPAN&gt;// not var url: '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F...%27%E2%80%8D" target="_blank"&gt;https://...'‍&lt;/A&gt;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; url &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;...'&lt;/SPAN&gt;&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;its hard to tell because of your indentation, but you're also missing a curly brace and closing parenthesis &lt;EM&gt;after&lt;/EM&gt; you add your L.geoJSON to the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. besides that, 'layer.geometry' is undefined. so you can't use 'layer.geometry.coordinates[1]' to access the latitude and longitude you're looking for within the `onEachFeature` function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'd recommend using a text editor with color highlighted syntax and tools to point out if each parenthesis and curly brace is closed (and where) to appropriately terminate functions. (like Sublime, VS Code or Notepad++).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;afterward you'll need to host your simple program using a local web server and open it in a browser. using the developer tools to set breakpoints and inspect variables is the only way you'll be able to learn exactly where things are going awry and make corrections quickly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 09:02:54 GMT</pubDate>
    <dc:creator>JohnGravois</dc:creator>
    <dc:date>2021-12-12T09:02:54Z</dc:date>
    <item>
      <title>Display esri leaflet feature's popup on open</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/display-esri-leaflet-feature-s-popup-on-open/m-p/790140#M177</link>
      <description>&lt;P&gt;I've recently started exploring leaflet and have tried&amp;nbsp;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&amp;nbsp;to open a popup. The attached code does not display a map but I've had bits and pieces working so I&amp;nbsp;think it's almost there. Any assistance much appreciated.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE class="lia-code-sample line-numbers language-none" tabindex="0"&gt;&lt;CODE&gt;&amp;lt;html&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset=utf-8 /&amp;gt;
  &amp;lt;title&amp;gt;Load each and every feature initially&amp;lt;/title&amp;gt;
  &amp;lt;meta name='viewport' content='initial-scale=1,maximum-scale=1,user-scalable=no' /&amp;gt;

    &amp;lt;!-- Load Leaflet from CDN --&amp;gt;
    &amp;lt;link rel="stylesheet" href="https://unpkg.com/leaflet@1.3.4/dist/leaflet.css"
    integrity="sha512-puBpdR0798OZvTTbP4A8Ix/l+A4dHDD0DGqYW6RQ+9jxkRFclaxxQb/SJAWZfWAkuyeQUytO7+7N4QKrDh+drA=="
    crossorigin=""/&amp;gt;
    &amp;lt;script src="https://unpkg.com/leaflet@1.3.4/dist/leaflet.js"
    integrity="sha512-nMMmRyTVoLYqjP9hrbed9S+FzjZHW5gY1TWCHA5ckwXZBadntCNs8kEqAWdrb9O7rxbCaA4lKTIWjDXZxflOcA=="
    crossorigin=""&amp;gt;&amp;lt;/script&amp;gt;


    &amp;lt;!-- Load Esri Leaflet from CDN --&amp;gt;
    &amp;lt;script src="https://unpkg.com/esri-leaflet@2.2.3/dist/esri-leaflet.js"
    integrity="sha512-YZ6b5bXRVwipfqul5krehD9qlbJzc6KOGXYsDjU9HHXW2gK57xmWl2gU6nAegiErAqFXhygKIsWPKbjLPXVb2g=="
    crossorigin=""&amp;gt;&amp;lt;/script&amp;gt;


  &amp;lt;style&amp;gt;
    body { margin:0; padding:0; }
    #map { position: absolute; top:0; bottom:0; right:0; left:0; }
  &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

&amp;lt;div id="map"&amp;gt;&amp;lt;/div&amp;gt;

&amp;lt;script&amp;gt;
  

  var map = L.map("map").setView([45.5666, -122.6921], 18);

  L.esri.basemapLayer("Topographic").addTo(map);


  var url:'https://services.arcgis.com/rOo16HdIMeOBI4Mb/arcgis/rest/services/Heritage_Trees_Portland/FeatureServer/0';
  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 = ' + feature.properties.COMMON_NAM)
                    .openOn(map);
                    var popupClick = layer.bindPopup('Name = ' + feature.properties.COMMON_NAM);
                }  

}).addTo(map);


&amp;lt;/script&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍&lt;/CODE&gt;&lt;/PRE&gt;</description>
      <pubDate>Mon, 28 Aug 2023 12:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/display-esri-leaflet-feature-s-popup-on-open/m-p/790140#M177</guid>
      <dc:creator>WilliamJackson3</dc:creator>
      <dc:date>2023-08-28T12:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: Display esri leaflet feature's popup on open</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/display-esri-leaflet-feature-s-popup-on-open/m-p/790141#M178</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;you have a bunch of different things going on.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;&lt;CODE&gt;&lt;SPAN class="comment token"&gt;&lt;SPAN&gt;// not var url: '&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F...%27%E2%80%8D" target="_blank"&gt;https://...'‍&lt;/A&gt;&lt;/SPAN&gt;
&lt;SPAN class="keyword token"&gt;var&lt;/SPAN&gt; url &lt;SPAN class="operator token"&gt;=&lt;/SPAN&gt; &lt;SPAN class="string token"&gt;&lt;SPAN&gt;'&lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=https%3A%2F%2F" target="_blank"&gt;https://&lt;/A&gt;&lt;SPAN&gt;...'&lt;/SPAN&gt;&lt;/SPAN&gt;‍‍‍‍&lt;SPAN class="line-numbers-rows"&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;SPAN&gt;‍&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2.&amp;nbsp;its hard to tell because of your indentation, but you're also missing a curly brace and closing parenthesis &lt;EM&gt;after&lt;/EM&gt; you add your L.geoJSON to the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;3. besides that, 'layer.geometry' is undefined. so you can't use 'layer.geometry.coordinates[1]' to access the latitude and longitude you're looking for within the `onEachFeature` function.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;i'd recommend using a text editor with color highlighted syntax and tools to point out if each parenthesis and curly brace is closed (and where) to appropriately terminate functions. (like Sublime, VS Code or Notepad++).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;afterward you'll need to host your simple program using a local web server and open it in a browser. using the developer tools to set breakpoints and inspect variables is the only way you'll be able to learn exactly where things are going awry and make corrections quickly.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 09:02:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/display-esri-leaflet-feature-s-popup-on-open/m-p/790141#M178</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2021-12-12T09:02:54Z</dc:date>
    </item>
  </channel>
</rss>

