<?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: Query Widget zoom to polygon code help in ArcGIS Web AppBuilder Questions</title>
    <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268004#M22919</link>
    <description>&lt;P&gt;This might be helpful.&amp;nbsp;&lt;A href="https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/setting-zoom-extent-for-attribute-table-zoom-to/m-p/802107" target="_blank" rel="noopener"&gt;setting-zoom-extent-for-attribute-table-zoom-to/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 15 Mar 2023 13:37:11 GMT</pubDate>
    <dc:creator>BrianLeroux</dc:creator>
    <dc:date>2023-03-15T13:37:11Z</dc:date>
    <item>
      <title>Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1267999#M22918</link>
      <description>&lt;P&gt;Hey all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;Im trying to configure the Query Widget in WAB Dev Edition so that when you click on a result of the query it will zoom to the shape of the polygon. Right now it zooms to a default zoom level but it too far out and I cannot figure out where to change the code to zoom to the shape.&lt;/P&gt;&lt;P&gt;Ive found the following code affects the zoom level because when i comment the code out it no longer zooms.&amp;nbsp; Ive tried to enter different zoomfactors into the geometry.getExtent() and extent.expand() but nothing changes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;html.addClass(tr, 'jimu-state-active');&lt;BR /&gt;var feature = tr.feature;&lt;BR /&gt;var geometry = feature.geometry;&lt;BR /&gt;if (geometry) {&lt;BR /&gt;var geoType = geometry.type;&lt;BR /&gt;var centerPoint, extent;&lt;BR /&gt;if (geoType === 'point') {&lt;BR /&gt;centerPoint = geometry;&lt;BR /&gt;} else if (geoType === 'multipoint') {&lt;BR /&gt;if (geometry.points.length === 1) {&lt;BR /&gt;centerPoint = geometry.getPoint(0);&lt;BR /&gt;} else if (geometry.points.length &amp;gt; 1) {&lt;BR /&gt;centerPoint = geometry.getPoint(0);&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;} else if (geoType === 'polyline') {&lt;BR /&gt;extent = geometry.getExtent();&lt;BR /&gt;extent = extent.expand(1.4);&lt;BR /&gt;centerPoint = extent.getCenter();&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;} else if (geoType === 'polygon') {&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;extent = geometry.getExtent();&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;extent = extent.expand(1.4);&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;centerPoint = extent.getCenter();&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;} else if (geoType === 'extent') {&lt;BR /&gt;extent = geometry;&lt;BR /&gt;extent = extent.expand(1.4);&lt;BR /&gt;centerPoint = extent.getCenter();&lt;BR /&gt;}&lt;BR /&gt;var featureSet = jimuUtils.toFeatureSet(feature);&lt;BR /&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet);&lt;BR /&gt;if (typeof this.map.infoWindow.setFeatures === 'function') {&lt;BR /&gt;this.map.infoWindow.setFeatures([feature]);&lt;BR /&gt;}&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:24:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1267999#M22918</guid>
      <dc:creator>JustinSharp</dc:creator>
      <dc:date>2023-03-15T13:24:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268004#M22919</link>
      <description>&lt;P&gt;This might be helpful.&amp;nbsp;&lt;A href="https://community.esri.com/t5/web-appbuilder-custom-widgets-questions/setting-zoom-extent-for-attribute-table-zoom-to/m-p/802107" target="_blank" rel="noopener"&gt;setting-zoom-extent-for-attribute-table-zoom-to/&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:37:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268004#M22919</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T13:37:11Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268008#M22920</link>
      <description>&lt;P&gt;I should also mention that it seems like the if sections in the code you posted are just getting a center point of and extent and not performing a zoom. The zooming looks to be handled on this line -&amp;nbsp;&lt;SPAN&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Personally I zoom in my widgets using&amp;nbsp;map.centerAndZoom (result.features[0].geometry,13); so I can set a zoom level.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:42:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268008#M22920</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T13:42:13Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268009#M22921</link>
      <description>&lt;P&gt;Thanks Brian I saw that post as well and tried that in the zoomToUtils.js but since its a polygon and not a point i couldnt get it to work.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:44:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268009#M22921</guid>
      <dc:creator>JustinSharp</dc:creator>
      <dc:date>2023-03-15T13:44:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268012#M22922</link>
      <description>&lt;P&gt;so where do you put the map.centerAndZoom code? I tried that as well in various places but did nothing.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 13:50:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268012#M22922</guid>
      <dc:creator>JustinSharp</dc:creator>
      <dc:date>2023-03-15T13:50:29Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268019#M22923</link>
      <description>&lt;P&gt;Here are a couple things to try. One I noteced that there is a extentFactor you can set on the zoomToFeatureSet function as seen here mo.zoomToFeatureSet = function(map, featureSet, /*optional*/extentFactor). So you could try playing with values there. For example try&amp;nbsp;&lt;SPAN&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet, 0.8);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;To try center and zoom I would comment out&amp;nbsp;jimuUtils.zoomToFeatureSet(this.map, featureSet); and add a new line of this.map.centerAndZoom (geometry,13);&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 14:00:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268019#M22923</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T14:00:14Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268052#M22924</link>
      <description>&lt;P&gt;unfortunately commenting out&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet);&amp;nbsp;&lt;/EM&gt;&lt;/STRONG&gt;breaks the code and does not pan or zoom and adding the extent factor to&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;STRONG&gt;&lt;EM&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet, #.#) &lt;/EM&gt;&lt;/STRONG&gt;does not change anything no matter what factor i put in.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 15:13:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268052#M22924</guid>
      <dc:creator>JustinSharp</dc:creator>
      <dc:date>2023-03-15T15:13:45Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268080#M22925</link>
      <description>&lt;P&gt;That is strange. I just tested with&amp;nbsp;jimuUtils.zoomToFeatureSet(this.map, featureSet,0.5); and it zoomed me in closer to the selected polygon feature. To the point where I couldn't see all edges of my polygon. I also tried using a value of 10 and it zoomed way out. Try using a lower value like 0.25 or even down to 0.1.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 15:42:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268080#M22925</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T15:42:24Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268092#M22926</link>
      <description>&lt;P&gt;I was able to test with map.centerAndZoon as well and that works. i did have to tweak what I initially put though as that function needs a single point. so this is what you would need. I do think using the other method above is a bit better though.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;//jimuUtils.zoomToFeatureSet(this.map, featureSet,0.5);&lt;BR /&gt;//console.log(centerPoint);&lt;BR /&gt;this.map.centerAndZoom(centerPoint,15);&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 15:57:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268092#M22926</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T15:57:41Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268218#M22932</link>
      <description>&lt;P&gt;&lt;SPAN&gt;jimuUtils.zoomToFeatureSet(this.map, featureSet);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;console.log(centerPoint);&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;this.map.centerAndZoom(centerPoint,20);&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;This worked! Thanks Brian!&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 19:35:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268218#M22932</guid>
      <dc:creator>JustinSharp</dc:creator>
      <dc:date>2023-03-15T19:35:01Z</dc:date>
    </item>
    <item>
      <title>Re: Query Widget zoom to polygon code help</title>
      <link>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268226#M22934</link>
      <description>&lt;P&gt;Yes I am. I am testing on a basic feature service of zip codes.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 19:30:24 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-web-appbuilder-questions/query-widget-zoom-to-polygon-code-help/m-p/1268226#M22934</guid>
      <dc:creator>BrianLeroux</dc:creator>
      <dc:date>2023-03-15T19:30:24Z</dc:date>
    </item>
  </channel>
</rss>

