<?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: Adding more functionality to my esri-leaflet app in Open Source Mapping Libraries Ques.</title>
    <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840657#M476</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the assist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 30 Sep 2015 15:16:27 GMT</pubDate>
    <dc:creator>joepublic</dc:creator>
    <dc:date>2015-09-30T15:16:27Z</dc:date>
    <item>
      <title>Adding click and zoom functionality</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840655#M474</link>
      <description>&lt;P&gt;I have the following app (&lt;A title="http://cloudtobago.com/icgc/icgcWebMap5.html" href="http://cloudtobago.com/icgc/icgcWebMap5.html" target="_blank"&gt;ICGC WEB PORTAL&lt;/A&gt;​)&amp;nbsp; Based on which button at the top clicked on, certain countries are highlighted, I&amp;nbsp; need help with the following:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I want to pan to(?)/center on the country clicked on as well as increase the zoom level.&lt;/P&gt;
&lt;P&gt;This is my attempt&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function getExtent(){&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var lat = map.getCenter().lat;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var lng = map.getCenter().lng;&lt;/P&gt;
&lt;P&gt;&amp;nbsp; var newCord = [lat, lng];&lt;/P&gt;
&lt;P&gt;&amp;nbsp; return newCord;&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function highlightFeature(e){&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var newCenter = getExtent();&amp;nbsp; &amp;lt;--&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; var layer = e.target&lt;/P&gt;
&lt;P&gt;&amp;nbsp; [stuff omitted]&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;function onEachFeature(feature, layer){&lt;/P&gt;
&lt;P&gt;&amp;nbsp; layer.on({&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; click: highlightFeature&lt;/P&gt;
&lt;P&gt;&amp;nbsp; });&lt;/P&gt;
&lt;P&gt;}&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;countries = L.geoJson(featureCollection, {&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&amp;nbsp; onEachFeature: onEachFeature&lt;/P&gt;
&lt;P&gt;}).addTo(map);&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Script attached&lt;/P&gt;</description>
      <pubDate>Mon, 28 Aug 2023 13:40:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840655#M474</guid>
      <dc:creator>joepublic</dc:creator>
      <dc:date>2023-08-28T13:40:01Z</dc:date>
    </item>
    <item>
      <title>Re: Adding more functionality to my esri-leaflet app</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840656#M475</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;the easiest thing to do would just be to listen for the 'click' event of your featureLayer and use that opportunity to retrieve its bounds and pass them to the map.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;featureLayer.on('click', function(evt) {
&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fleafletjs.com%2Freference.html%23featuregroup-getbounds" target="_blank"&gt;http://leafletjs.com/reference.html#featuregroup-getbounds&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; var bounds = evt.layer.getBounds()
&lt;SPAN&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; // &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="https://community.esri.com/external-link.jspa?url=http%3A%2F%2Fleafletjs.com%2Freference.html%23map-fitbounds" target="_blank"&gt;http://leafletjs.com/reference.html#map-fitbounds&lt;/A&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; map.fitBounds(bounds);
});&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;this is possible because 'L.esri.FeatureLayer' extends 'L.geoJson' and 'L.geoJson' extends 'L.featureGroup', which has a method 'getBounds()'.&amp;nbsp; you can find a working example &lt;A href="https://dl.dropboxusercontent.com/u/59331579/js/clickZoom.html" rel="nofollow noopener noreferrer" target="_blank"&gt;here&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;between all the inheritance and the fact that the documentation for Esri Leaflet and Leaflet itself are in two different places, stuff like this can be confusing until you get the hang of it.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 10:15:47 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840656#M475</guid>
      <dc:creator>JohnGravois</dc:creator>
      <dc:date>2021-12-12T10:15:47Z</dc:date>
    </item>
    <item>
      <title>Re: Adding more functionality to my esri-leaflet app</title>
      <link>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840657#M476</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;John,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks for the assist&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Chris&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 30 Sep 2015 15:16:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/open-source-mapping-libraries-ques/adding-click-and-zoom-functionality/m-p/840657#M476</guid>
      <dc:creator>joepublic</dc:creator>
      <dc:date>2015-09-30T15:16:27Z</dc:date>
    </item>
  </channel>
</rss>

