<?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: automatic zoom to layer in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204651#M18968</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A dynamic map service has a property fullextent, so you do not need to do the calculation on the features. However, it will be available at the onload event of the map service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So you simple need to handle the onload event of the map service to have the full extent of the map service.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 02 Jul 2012 05:30:07 GMT</pubDate>
    <dc:creator>JohnnyPenet</dc:creator>
    <dc:date>2012-07-02T05:30:07Z</dc:date>
    <item>
      <title>automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204647#M18964</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I'm trying to zoom to layer automatically as soon as the map finishes loading using the guide &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=261204" rel="nofollow" target="_blank"&gt;here&lt;/A&gt;&lt;SPAN&gt;. To be clear, I'm only loading one layer and just want to zoom in on one of the layers provided by the service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;js script&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;dojo.require("dijit.layout.BorderContainer"); dojo.require("dijit.layout.ContentPane"); dojo.require("esri.map"); dojo.require("esri.renderer"); dojo.require("esri.graphic"); dojo.require("esri.dijit.Legend"); dojo.require("esri.utils");&amp;nbsp; dojo.require("dijit.layout.AccordionContainer"); dojo.require("esri.layers.FeatureLayer");&amp;nbsp; var map; var basemap; var trafficmap; var basemapServiceSource; var featuremapServiceSource; var trafficServiceSource; var renderer; var loading;&amp;nbsp; function init() {&amp;nbsp;&amp;nbsp; // for now, these are referring to a single source&amp;nbsp; basemapServiceSource = "http://co-gis-01/ArcGIS/rest/services/dev_RTIA/rtia/MapServer";&amp;nbsp;&amp;nbsp; //Add the topographic layer to the map. View the ArcGIS Online site for services http://arcgisonline/home/search.html?t=content&amp;amp;f=typekeywords:service&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; basemap = new esri.layers.ArcGISDynamicMapServiceLayer(basemapServiceSource);&amp;nbsp; basemap.setVisibleLayers([0, 1, 2, 4, 5, 6]);&amp;nbsp;&amp;nbsp; map = new esri.Map("map", {&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; // remove logo &amp;nbsp;&amp;nbsp; logo:false &amp;nbsp; });&amp;nbsp;&amp;nbsp; //loading image. id&amp;nbsp; loading = dojo.byId("loadingImg");&amp;nbsp; dojo.connect(map,"onUpdateStart",showLoading);&amp;nbsp; dojo.connect(map,"onUpdateEnd",hideLoading); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /* &amp;nbsp; IDs of Layers for http://co-gis-01/ArcGIS/rest/services/dev_ExIS/exis/MapServer &amp;nbsp;&amp;nbsp; Site Name (0) &amp;nbsp;&amp;nbsp; Section ID (1) &amp;nbsp;&amp;nbsp; AADT some (2) &amp;nbsp;&amp;nbsp; AADT all (3) &amp;nbsp;&amp;nbsp; AdministrativeAreas_CongressionalDistricts (4) &amp;nbsp;&amp;nbsp; AdministrativeAreas_Provinces (5) &amp;nbsp;&amp;nbsp; AdministrativeAreas_Regions (6)&amp;nbsp; */&amp;nbsp; map.addLayer(basemap);&amp;nbsp;&amp;nbsp; // executes function on onLoad event&amp;nbsp; dojo.connect(map, 'onLoad', function(theMap) {&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; dojo.connect(dijit.byId('map'), 'resize', map,map.resize); &amp;nbsp; zoomToLayer();&amp;nbsp; }); }&amp;nbsp;&amp;nbsp; function zoomToLayer() {&amp;nbsp;&amp;nbsp; var requestHandle = esri.request({ &amp;nbsp; url: "http://co-gis-01/ArcGIS/rest/services/dev_RTIA/rtia/MapServer/2", &amp;nbsp; content: { f:"json" }, &amp;nbsp; callbackParamName: "callback"&amp;nbsp; });&amp;nbsp;&amp;nbsp;&amp;nbsp; requestHandle.then(requestSucceeded, requestFailed); }&amp;nbsp; function requestSucceeded(response, io) {&amp;nbsp;&amp;nbsp; var extent = new esri.geometry.Extent(response.extent);&amp;nbsp; dojo.byId("extent").innerHTML = dojo.toJson(extent.toJson());&amp;nbsp; map.setExtent(extent); }&amp;nbsp; function requestFailed() {&amp;nbsp;&amp;nbsp; alert("requestFailed"); }&amp;nbsp; function showLoading() {&amp;nbsp;&amp;nbsp; esri.show(loading);&amp;nbsp; map.disableMapNavigation();&amp;nbsp; map.hideZoomSlider(); }&amp;nbsp; function hideLoading(error) {&amp;nbsp;&amp;nbsp; esri.hide(loading);&amp;nbsp; map.enableMapNavigation();&amp;nbsp; map.showZoomSlider();&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp; dojo.addOnLoad(init);&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;html code&lt;/SPAN&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;&amp;lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&amp;gt; &amp;lt;html&amp;gt; &amp;nbsp; &amp;lt;head&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;title&amp;gt;RTIA Map&amp;lt;/title&amp;gt;&amp;nbsp; &amp;lt;meta http-equiv="X-UA-Compatible" content="IE=EmulateIE8" &amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;link rel="stylesheet" type="text/css" href="gis.css" /&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;script type="text/javascript" src="http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.8"&amp;gt;&amp;lt;/script&amp;gt;&amp;nbsp; &amp;lt;script type="text/javascript" src="rtia_culled.js"&amp;gt;&amp;lt;/script&amp;gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp; &amp;lt;/head&amp;gt; &amp;nbsp;&amp;nbsp; &amp;lt;body&amp;gt; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;div id="map" class="mainmap"&amp;gt; &amp;nbsp; &amp;lt;img id="loadingImg" src="images/loading.gif" class="loadimage"/&amp;gt;&amp;nbsp; &amp;lt;/div&amp;gt;&amp;nbsp; &amp;lt;!--div id="legendDiv" style="width:600px; height:600px; border:1px solid #000"--&amp;gt;&amp;nbsp; &amp;lt;/div&amp;gt;&amp;nbsp;&amp;nbsp; &amp;lt;span id="extent"&amp;gt;&amp;lt;/span&amp;gt; &amp;lt;/body&amp;gt;&amp;nbsp; &amp;lt;/html&amp;gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;The problem is that the outputs of dojo.toJson(extent.toJson()) show the same extent, which is the full extent, no matter the layer. This particular layer that I would like to zoom to, &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://co-gis-01/ArcGIS/rest/services/dev_RTIA/rtia/MapServer/2" rel="nofollow" target="_blank"&gt;http://co-gis-01/ArcGIS/rest/services/dev_RTIA/rtia/MapServer/2&lt;/A&gt;&lt;SPAN&gt;, is just a filtered version of one of the "full-extent" layers. The filter is defined in the mapservice.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;How do I correctly do this function?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 00:00:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204647#M18964</guid>
      <dc:creator>Egan_LouisFajardo</dc:creator>
      <dc:date>2012-06-28T00:00:36Z</dc:date>
    </item>
    <item>
      <title>Re: automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204648#M18965</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried setting only the layer of interest as visible, and then setting the map extent to full extent. Still, only the whole full extent is displayed instead of the extent that can only be shown by the layer.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 00:46:26 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204648#M18965</guid>
      <dc:creator>Egan_LouisFajardo</dc:creator>
      <dc:date>2012-06-28T00:46:26Z</dc:date>
    </item>
    <item>
      <title>Re: automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204649#M18966</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I tried exporting the filtered layer and importing it, resulting in a layer whose content is only those originally defined by the definition query. I published the service and was finally able to automatically zoom to the desired extent. The definition query seems to be ignored when getting the full extent of the layer, in other words, the full extent still considers all features, even those that fails the definition query. is there a way to circumvent this in the api?&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 28 Jun 2012 05:05:18 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204649#M18966</guid>
      <dc:creator>Egan_LouisFajardo</dc:creator>
      <dc:date>2012-06-28T05:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204650#M18967</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;I've managed to solve this problem using &lt;/SPAN&gt;&lt;A class="jive-link-external-small" href="http://forums.esri.com/Thread.asp?c=158&amp;amp;f=2396&amp;amp;t=266110" rel="nofollow" target="_blank"&gt;this&lt;/A&gt;&lt;SPAN&gt; as a reference. Basically, I looped all of the Polyline graphics (that's the only type the application is interested in) included in the FeatureLayer and do a union operation on each of the graphic's extent. Below is my version.&lt;/SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;PRE class="plain" name="code"&gt;function featureUpdateEnd(error, info) {&amp;nbsp;&amp;nbsp; var localExtent;&amp;nbsp; if (featuremap.graphics.length &amp;gt; 0) {&amp;nbsp;&amp;nbsp; &amp;nbsp; for (var i = 0; i &amp;lt; featuremap.graphics.length; i++) { &amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; if (featuremap.graphics&lt;I&gt;.geometry instanceof esri.geometry.Polyline) { &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (i == 0) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; localExtent = new esri.geometry.Extent(featuremap.graphics&lt;I&gt;.geometry.getExtent().toJson()); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; localExtent = localExtent.union(featuremap.graphics&lt;I&gt;.geometry.getExtent()); &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp;&amp;nbsp; catch (err) { &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; //alert(String(i) + " is caught: " + err.message); &amp;nbsp;&amp;nbsp;&amp;nbsp; } &amp;nbsp;&amp;nbsp; } &amp;nbsp; } &amp;nbsp;&amp;nbsp; &amp;nbsp; localExtent = localExtent.expand(1.25); &amp;nbsp; map.setExtent(localExtent.getExtent());&amp;nbsp; } }&lt;/I&gt;&lt;/I&gt;&lt;/I&gt;&lt;/PRE&gt;&lt;DIV style="display:none;"&gt; &lt;/DIV&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;SPAN&gt;featuremap is the FeatureLayer. featureUpdateEnd is a function that is called by FeatureLayer's onUpdateEnd event. I did not use onLoad because the event fires even if the FeatureLayer hasn't finished loading yet, giving me a zero-length array to loop on. I had to enclose part of it in a try-catch statement because of an undefined instance is encountered (but this is probably only due to my data).&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 01:38:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204650#M18967</guid>
      <dc:creator>Egan_LouisFajardo</dc:creator>
      <dc:date>2012-07-02T01:38:11Z</dc:date>
    </item>
    <item>
      <title>Re: automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204651#M18968</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;A dynamic map service has a property fullextent, so you do not need to do the calculation on the features. However, it will be available at the onload event of the map service.&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;So you simple need to handle the onload event of the map service to have the full extent of the map service.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 02 Jul 2012 05:30:07 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204651#M18968</guid>
      <dc:creator>JohnnyPenet</dc:creator>
      <dc:date>2012-07-02T05:30:07Z</dc:date>
    </item>
    <item>
      <title>Re: automatic zoom to layer</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204652#M18969</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;SPAN&gt;As explained in my first post, I cannot use the respective fullExtent of the dynamically segmented layer as it references the fullExtent of the the layer it originated from.&lt;/SPAN&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 03 Jul 2012 00:15:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/automatic-zoom-to-layer/m-p/204652#M18969</guid>
      <dc:creator>Egan_LouisFajardo</dc:creator>
      <dc:date>2012-07-03T00:15:21Z</dc:date>
    </item>
  </channel>
</rss>

