<?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 Zoom to layer extent from start in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1046815#M72519</link>
    <description>&lt;P&gt;I want to zoom in to my feature layer automatically from start without having to write the coordinates for it in view. Right now we get an error when doing queryExtent() and then&amp;nbsp;view.goTo(response.extent) that says the following: undefined "TypeError" cannot read the property "TargetGeometry" of Null". Have searched all over this community but haven't found anyone with a similar problem. Would appreciate some help! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is our code so far!&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;ArcGIS API for JavaScript Tutorials: Query a feature layer (spatial)&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html, body, #viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 100%;&lt;BR /&gt;width: 100%;&lt;BR /&gt;}&lt;BR /&gt;#Zoom{&lt;BR /&gt;top: 240px;&lt;BR /&gt;right: 20px;&lt;BR /&gt;position: absolute;&lt;BR /&gt;z-index: 99;&lt;BR /&gt;background-color: white;&lt;BR /&gt;border-radius: 8px;&lt;BR /&gt;border-width: 2px;&lt;BR /&gt;border-style: solid;&lt;BR /&gt;border-color: black;&lt;BR /&gt;padding: 10px;&lt;BR /&gt;opacity: 1;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.18/esri/themes/light/main.css" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.18/esri/themes/light/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&lt;/A&gt;&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;require([&lt;BR /&gt;"esri/config",&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/widgets/Sketch",&lt;BR /&gt;"esri/layers/GraphicsLayer",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/widgets/Search",&lt;BR /&gt;"esri/renderers/ClassBreaksRenderer",&lt;BR /&gt;"esri/widgets/Legend","esri/views/SceneView",&lt;/P&gt;&lt;P&gt;], function(esriConfig,Map, MapView, Sketch, GraphicsLayer, FeatureLayer,Graphic,Search,ClassBreaksRenderer,Legend) {&lt;/P&gt;&lt;P&gt;esriConfig.apiKey = "AAPKac92afe710ec4db9bf8423343102b147tLzn_6tk50TFgDBNl63Tr-44V9blp4Njp8ffo7faiUeI0K_9qJpyVRV2xLm6y2Zc";&lt;BR /&gt;&lt;BR /&gt;// Reference query layer&lt;BR /&gt;const parcelLayer = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services9.arcgis.com/S990USlhfgpUmWKm/ArcGIS/rest/services/L%c3%a4ggtillkarta/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services9.arcgis.com/S990USlhfgpUmWKm/ArcGIS/rest/services/L%c3%a4ggtillkarta/FeatureServer/0&lt;/A&gt;",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;id: "incidentsLayer",&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;const map = new Map({&lt;BR /&gt;basemap: "arcgis-topographic" //Basemap layer service&lt;BR /&gt;});&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;layers: [parcelLayer],&lt;BR /&gt;extent: {&lt;BR /&gt;// autocasts as new Extent()&lt;BR /&gt;xmin: 524550,&lt;BR /&gt;ymin: 6474400,&lt;BR /&gt;xmax: 527600,&lt;BR /&gt;ymax: 6477200,&lt;BR /&gt;spatialReference: 102100&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function zoomToLayer(layer) {&lt;BR /&gt;return layer.queryExtent().then(function(response) {&lt;BR /&gt;var opts = {duration: 5000};&lt;BR /&gt;response.outSpatialReference = view.spatialReference;&lt;BR /&gt;// go to point at LOD 15 with custom duration&lt;BR /&gt;view.goTo(response.extent, opts)&lt;BR /&gt;.catch(function(error){&lt;BR /&gt;if (error.name != "AbortError"){&lt;BR /&gt;console.log("===============================================");&lt;BR /&gt;console.error(&lt;BR /&gt;error.code,&lt;BR /&gt;error.name,&lt;BR /&gt;error.message&lt;BR /&gt;);&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;map.add(parcelLayer);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;var ZoomToggle = document.getElementById("Zoom");&lt;BR /&gt;// Listen to the change event for the checkbox&lt;BR /&gt;ZoomToggle.addEventListener("click", function() {&lt;BR /&gt;zoomToLayer(parcelLayer)&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv2"&amp;gt; &amp;lt;button id="Zoom" class="esri-widget"&amp;gt; Zoom to layer&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;p id="result"&amp;gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
    <pubDate>Wed, 14 Apr 2021 09:21:13 GMT</pubDate>
    <dc:creator>WilliamHepp</dc:creator>
    <dc:date>2021-04-14T09:21:13Z</dc:date>
    <item>
      <title>Zoom to layer extent from start</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1046815#M72519</link>
      <description>&lt;P&gt;I want to zoom in to my feature layer automatically from start without having to write the coordinates for it in view. Right now we get an error when doing queryExtent() and then&amp;nbsp;view.goTo(response.extent) that says the following: undefined "TypeError" cannot read the property "TargetGeometry" of Null". Have searched all over this community but haven't found anyone with a similar problem. Would appreciate some help! &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is our code so far!&lt;BR /&gt;&amp;lt;html&amp;gt;&lt;BR /&gt;&amp;lt;head&amp;gt;&lt;BR /&gt;&amp;lt;meta charset="utf-8"&amp;gt;&lt;BR /&gt;&amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no"&amp;gt;&lt;BR /&gt;&amp;lt;title&amp;gt;ArcGIS API for JavaScript Tutorials: Query a feature layer (spatial)&amp;lt;/title&amp;gt;&lt;BR /&gt;&amp;lt;style&amp;gt;&lt;BR /&gt;html, body, #viewDiv {&lt;BR /&gt;padding: 0;&lt;BR /&gt;margin: 0;&lt;BR /&gt;height: 100%;&lt;BR /&gt;width: 100%;&lt;BR /&gt;}&lt;BR /&gt;#Zoom{&lt;BR /&gt;top: 240px;&lt;BR /&gt;right: 20px;&lt;BR /&gt;position: absolute;&lt;BR /&gt;z-index: 99;&lt;BR /&gt;background-color: white;&lt;BR /&gt;border-radius: 8px;&lt;BR /&gt;border-width: 2px;&lt;BR /&gt;border-style: solid;&lt;BR /&gt;border-color: black;&lt;BR /&gt;padding: 10px;&lt;BR /&gt;opacity: 1;&lt;BR /&gt;}&lt;BR /&gt;&amp;lt;/style&amp;gt;&lt;BR /&gt;&amp;lt;link rel="stylesheet" href="&lt;A href="https://js.arcgis.com/4.18/esri/themes/light/main.css" target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.18/esri/themes/light/main.css&lt;/A&gt;"&amp;gt;&lt;BR /&gt;&amp;lt;script src="&lt;A target="_blank" rel="noopener"&gt;https://js.arcgis.com/4.18/"&amp;gt;&amp;lt;/script&lt;/A&gt;&amp;gt;&lt;BR /&gt;&amp;lt;script&amp;gt;&lt;BR /&gt;&lt;BR /&gt;require([&lt;BR /&gt;"esri/config",&lt;BR /&gt;"esri/Map",&lt;BR /&gt;"esri/views/MapView",&lt;BR /&gt;"esri/widgets/Sketch",&lt;BR /&gt;"esri/layers/GraphicsLayer",&lt;BR /&gt;"esri/layers/FeatureLayer",&lt;BR /&gt;"esri/Graphic",&lt;BR /&gt;"esri/widgets/Search",&lt;BR /&gt;"esri/renderers/ClassBreaksRenderer",&lt;BR /&gt;"esri/widgets/Legend","esri/views/SceneView",&lt;/P&gt;&lt;P&gt;], function(esriConfig,Map, MapView, Sketch, GraphicsLayer, FeatureLayer,Graphic,Search,ClassBreaksRenderer,Legend) {&lt;/P&gt;&lt;P&gt;esriConfig.apiKey = "AAPKac92afe710ec4db9bf8423343102b147tLzn_6tk50TFgDBNl63Tr-44V9blp4Njp8ffo7faiUeI0K_9qJpyVRV2xLm6y2Zc";&lt;BR /&gt;&lt;BR /&gt;// Reference query layer&lt;BR /&gt;const parcelLayer = new FeatureLayer({&lt;BR /&gt;url: "&lt;A href="https://services9.arcgis.com/S990USlhfgpUmWKm/ArcGIS/rest/services/L%c3%a4ggtillkarta/FeatureServer/0" target="_blank" rel="noopener"&gt;https://services9.arcgis.com/S990USlhfgpUmWKm/ArcGIS/rest/services/L%c3%a4ggtillkarta/FeatureServer/0&lt;/A&gt;",&lt;BR /&gt;outFields: ["*"],&lt;BR /&gt;id: "incidentsLayer",&lt;BR /&gt;});&lt;BR /&gt;&lt;BR /&gt;const map = new Map({&lt;BR /&gt;basemap: "arcgis-topographic" //Basemap layer service&lt;BR /&gt;});&lt;BR /&gt;const view = new MapView({&lt;BR /&gt;container: "viewDiv",&lt;BR /&gt;map: map,&lt;BR /&gt;layers: [parcelLayer],&lt;BR /&gt;extent: {&lt;BR /&gt;// autocasts as new Extent()&lt;BR /&gt;xmin: 524550,&lt;BR /&gt;ymin: 6474400,&lt;BR /&gt;xmax: 527600,&lt;BR /&gt;ymax: 6477200,&lt;BR /&gt;spatialReference: 102100&lt;BR /&gt;}&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;function zoomToLayer(layer) {&lt;BR /&gt;return layer.queryExtent().then(function(response) {&lt;BR /&gt;var opts = {duration: 5000};&lt;BR /&gt;response.outSpatialReference = view.spatialReference;&lt;BR /&gt;// go to point at LOD 15 with custom duration&lt;BR /&gt;view.goTo(response.extent, opts)&lt;BR /&gt;.catch(function(error){&lt;BR /&gt;if (error.name != "AbortError"){&lt;BR /&gt;console.log("===============================================");&lt;BR /&gt;console.error(&lt;BR /&gt;error.code,&lt;BR /&gt;error.name,&lt;BR /&gt;error.message&lt;BR /&gt;);&lt;BR /&gt;}&lt;BR /&gt;});&lt;BR /&gt;});&lt;BR /&gt;}&lt;BR /&gt;map.add(parcelLayer);&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;var ZoomToggle = document.getElementById("Zoom");&lt;BR /&gt;// Listen to the change event for the checkbox&lt;BR /&gt;ZoomToggle.addEventListener("click", function() {&lt;BR /&gt;zoomToLayer(parcelLayer)&lt;BR /&gt;});&lt;/P&gt;&lt;P&gt;});&lt;BR /&gt;&amp;lt;/script&amp;gt;&lt;BR /&gt;&amp;lt;/head&amp;gt;&lt;BR /&gt;&amp;lt;body&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;div id="viewDiv2"&amp;gt; &amp;lt;button id="Zoom" class="esri-widget"&amp;gt; Zoom to layer&amp;lt;/button&amp;gt;&amp;lt;/div&amp;gt;&lt;BR /&gt;&amp;lt;p id="result"&amp;gt;&amp;lt;/p&amp;gt;&lt;BR /&gt;&amp;lt;/body&amp;gt;&lt;BR /&gt;&amp;lt;/html&amp;gt;&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 09:21:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1046815#M72519</guid>
      <dc:creator>WilliamHepp</dc:creator>
      <dc:date>2021-04-14T09:21:13Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer extent from start</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1046847#M72520</link>
      <description>&lt;P&gt;There's something wrong with that feature layer (using "0" instead of "..."). I substituted another feature layer in the URL and it worked properly.&lt;/P&gt;</description>
      <pubDate>Wed, 14 Apr 2021 12:34:54 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1046847#M72520</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-04-14T12:34:54Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer extent from start</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1047440#M72550</link>
      <description>&lt;P&gt;Ok thank you. What do you mean with using "0" instead of "..."? Do you know why my feature layer is not working because I created that feature layer and would like for it to work on it.&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 08:02:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1047440#M72550</guid>
      <dc:creator>WilliamHepp</dc:creator>
      <dc:date>2021-04-15T08:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer extent from start</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1047512#M72554</link>
      <description>&lt;P&gt;You're correct in the URL worked properly in your original code, since the layer is drawn on your map. If you don't specify a layer, it defaults to the first layer in your service.&lt;/P&gt;&lt;P&gt;However, I'm not sure why yours isn't working properly in the code. How did you create it?&lt;/P&gt;</description>
      <pubDate>Thu, 15 Apr 2021 13:00:27 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1047512#M72554</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-04-15T13:00:27Z</dc:date>
    </item>
    <item>
      <title>Re: Zoom to layer extent from start</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1048005#M72585</link>
      <description>&lt;P&gt;I create it from a TIF file in ArcGIS pro and then converted it to a shapefile and published it as a web layer. is there some setting I have forgotten to turn on?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Apr 2021 07:40:29 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/zoom-to-layer-extent-from-start/m-p/1048005#M72585</guid>
      <dc:creator>WilliamHepp</dc:creator>
      <dc:date>2021-04-16T07:40:29Z</dc:date>
    </item>
  </channel>
</rss>

