<?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: Get selected single point geometry, use in map.centerAndZoom in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591684#M55308</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is my code I came up with for a zoom button that works nicely. Works if multiple points or a single point is selected.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(dom.byId("zoomToSelectedD1Activities"), "click", function () {
&amp;nbsp; var countp = activitiesDay1.getSelectedFeatures().length;
&amp;nbsp; if (countp &amp;gt; 1) {
&amp;nbsp; map.setExtent(graphicsUtils.graphicsExtent(activitiesDay1.getSelectedFeatures()), true);
&amp;nbsp; } else {
&amp;nbsp; var mp1A = activitiesDay1.getSelectedFeatures()[0].geometry;
&amp;nbsp; map.centerAndZoom(mp1A, 18);
&amp;nbsp; }
&amp;nbsp; });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Sun, 12 Dec 2021 01:25:01 GMT</pubDate>
    <dc:creator>DavidChrest</dc:creator>
    <dc:date>2021-12-12T01:25:01Z</dc:date>
    <item>
      <title>Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591679#M55303</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I can easily zoom to a selection of points in my FeatureLayer with this handy one-liner:&lt;/P&gt;&lt;P&gt;map.setExtent(graphicsUtils.graphicsExtent(myFeatureLayer.getSelectedFeatures()), true);&lt;/P&gt;&lt;P&gt;In this case, it's assigned to a button.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;How do I utilize the map.centerAndZoom when just a single point of my Feature Layer is selected?&lt;/P&gt;&lt;P&gt;Just want to assign to a different button. I can't seem to find the exact syntax but I know I need to grab the geometry of the single selected point to then use in map.centerAndZoom.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thnks so much. Any help is greatly appreciated.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;David&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Oct 2015 07:27:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591679#M55303</guid>
      <dc:creator>DavidChrest</dc:creator>
      <dc:date>2015-10-06T07:27:02Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591680#M55304</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp; Here is some code I use:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;if (gExt) {
&amp;nbsp; map.setExtent(gExt.expand(1.5), true);
} else {
&amp;nbsp; var mp2 = currentLayerAdded.graphics[0].geometry;
&amp;nbsp; map.centerAndZoom(mp2, 12);
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:24:53 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591680#M55304</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T01:24:53Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591681#M55305</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Finally figured out how to insert code nicely to my replies. Here is my quick and dirty zoom and center fix for a single selected feature:&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(dom.byId("zoomToSelectedPoint"), "click", function () {
&amp;nbsp; centermap();
&amp;nbsp; setTimeout(function () {
&amp;nbsp; zoomin17();
&amp;nbsp; }, 500);
&amp;nbsp; });


&amp;nbsp; function centermap() {
&amp;nbsp; map.setExtent(graphicsUtils.graphicsExtent(activitiesDay1.getSelectedFeatures()), true);
&amp;nbsp; }


&amp;nbsp; function zoomin17() {
&amp;nbsp; map.setZoom(17);
&amp;nbsp; }&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:24:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591681#M55305</guid>
      <dc:creator>DavidChrest</dc:creator>
      <dc:date>2021-12-12T01:24:56Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591682#M55306</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;So it would look more like this then:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;var gExt = graphicsUtils.graphicsExtent(myFeatureLayher.getSelectedFeatures());
if (gExt) { 
&amp;nbsp; map.setExtent(gExt.expand(1.5), true); 
} else { 
&amp;nbsp; var mp2 = myFeatureLayher.getSelectedFeatures()[0].geometry; 
&amp;nbsp; map.centerAndZoom(mp2, 17); 
}&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:24:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591682#M55306</guid>
      <dc:creator>RobertScheitlin__GISP</dc:creator>
      <dc:date>2021-12-12T01:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591683#M55307</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Aha! That's it. Thanks so much, Robert. I was trying this last night but had forgotten the "()" between "getSelectedFeatures" and "[0]." Silly me. That's what happens when you stay up 'til 3:00 AM coding.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 06 Oct 2015 16:24:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591683#M55307</guid>
      <dc:creator>DavidChrest</dc:creator>
      <dc:date>2015-10-06T16:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Get selected single point geometry, use in map.centerAndZoom</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591684#M55308</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Here is my code I came up with for a zoom button that works nicely. Works if multiple points or a single point is selected.&lt;/P&gt;&lt;PRE class="lia-code-sample line-numbers language-none"&gt;on(dom.byId("zoomToSelectedD1Activities"), "click", function () {
&amp;nbsp; var countp = activitiesDay1.getSelectedFeatures().length;
&amp;nbsp; if (countp &amp;gt; 1) {
&amp;nbsp; map.setExtent(graphicsUtils.graphicsExtent(activitiesDay1.getSelectedFeatures()), true);
&amp;nbsp; } else {
&amp;nbsp; var mp1A = activitiesDay1.getSelectedFeatures()[0].geometry;
&amp;nbsp; map.centerAndZoom(mp1A, 18);
&amp;nbsp; }
&amp;nbsp; });&lt;/PRE&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Sun, 12 Dec 2021 01:25:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/get-selected-single-point-geometry-use-in-map/m-p/591684#M55308</guid>
      <dc:creator>DavidChrest</dc:creator>
      <dc:date>2021-12-12T01:25:01Z</dc:date>
    </item>
  </channel>
</rss>

