<?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: load map and 'goto' specific feature (polyline) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1116429#M75268</link>
    <description>&lt;P&gt;Awesome that was enough advice to get me there... here's what worked for me... it adds the layer to the map, zooms to it, then removes it... which also creates a better user experience because it doesn't snap back the map everytime you try to pan or zoom away...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      require(["esri/config","esri/Map","esri/WebMap", "esri/views/MapView","esri/layers/FeatureLayer","esri/widgets/ScaleBar","esri/widgets/Legend"], function (esriConfig,Map,WebMap, MapView, FeatureLayer, ScaleBar, Legend) {
        esriConfig.apiKey = "YOUR_KEY_HERE";

        const webmap = new WebMap({
          portalItem: {
            id: "4170f5e65bd8409896a906264e4c2c87"
          }        
        });
      

        const view = new MapView({
          map: webmap,
          container: "viewDiv" // Div element
        });


        const layer = new FeatureLayer({
          // URL to the service
          url: "https://services3.arcgis.com/pCmV4YWmyIH9CmGq/ArcGIS/rest/services/Crossing_Guards_VIEW/FeatureServer/0",
          definitionExpression: "OBJECTID = " + getUrlParameter('objectid')

        });
        view.map.add(layer);

        const scalebar = new ScaleBar({
        view: view        
        });

        view.ui.add(scalebar, "bottom-left");        

        view.whenLayerView(layer).then(function(layerView){
          layerView.watch("updating", function(val){
            // wait for the layer view to finish updating
            if(!val){
              layerView.queryExtent().then(function(response){
                // go to the extent of all the graphics in the layer view
                view.goTo({target:response.extent, zoom: 17});
                view.map.remove(layer);
              });              
            }
          });
        });


        
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 12 Nov 2021 17:46:33 GMT</pubDate>
    <dc:creator>AwesomeEvan</dc:creator>
    <dc:date>2021-11-12T17:46:33Z</dc:date>
    <item>
      <title>load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114757#M75188</link>
      <description>&lt;P&gt;Hey I'm simply looking to load a map and pan/zoom to a feature.&lt;/P&gt;&lt;P&gt;Here is the actual page.&amp;nbsp;&lt;A href="https://data.orangeville.ca/Apps/CrossingGuards/index.html?objectid=1" target="_blank" rel="noopener"&gt;https://data.orangeville.ca/Apps/CrossingGuards/index.html?objectid=1&lt;/A&gt;&lt;/P&gt;&lt;P&gt;I'm looking for help to get the inline map to 'goto' or &lt;EM&gt;pan and zoom&lt;/EM&gt; a feature based on object id&lt;/P&gt;&lt;P&gt;I'm getting the objectid from a url parameter using&lt;/P&gt;&lt;LI-CODE lang="java"&gt;        var getUrlParameter = function getUrlParameter(sParam) {  
          var sPageURL = decodeURIComponent(window.location.search.substring(1)),  
            sURLVariables = sPageURL.split('&amp;amp;'),  
            sParameterName,  
            i;  
        
          for (i = 0; i &amp;lt; sURLVariables.length; i++) {  
            sParameterName = sURLVariables[i].split('=');  
        
            if (sParameterName[0] === sParam) {  
              return sParameterName[1] === undefined ? true : sParameterName[1];  
            }  
          }  
        };   &lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and calling it using &amp;gt;&amp;gt;&amp;gt; getUrlParameter('objectid')&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also the map has 4 layers, the one to search is layer 3 of 4 called 'Crossing Guards VIEW'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;here is my codepen code just for the map for testing, with the api key removed...&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;&amp;lt;!--

To run this demo, you need to replace 'YOUR_API_KEY' with an API key from the ArcGIS Developer dashboard.

Sign up for a free account and get an API key.

https://developers.arcgis.com/documentation/mapping-apis-and-services/get-started/

 --&amp;gt;&amp;lt;html&amp;gt;
  &amp;lt;head&amp;gt;
    &amp;lt;meta charset="utf-8" /&amp;gt;
    &amp;lt;meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no" /&amp;gt;
    &amp;lt;title&amp;gt;ArcGIS API for JavaScript Tutorials: Display a map&amp;lt;/title&amp;gt;

    &amp;lt;style&amp;gt;
      html,
      body,
      #viewDiv {
        padding: 0;
        margin: 0;
        height: 100%;
        width: 100%;
      }
    &amp;lt;/style&amp;gt;

    &amp;lt;link rel="stylesheet" href="https://js.arcgis.com/4.21/esri/themes/light/main.css"&amp;gt;
    &amp;lt;script src="https://js.arcgis.com/4.21/"&amp;gt;&amp;lt;/script&amp;gt;

    &amp;lt;script&amp;gt;
      require(["esri/config","esri/WebMap", "esri/views/MapView","esri/widgets/ScaleBar","esri/widgets/Legend"], function (esriConfig,WebMap, MapView, ScaleBar, Legend) {

        esriConfig.apiKey = "API_KEY_HERE";

      const webmap = new WebMap({
        portalItem: {
          id: "4170f5e65bd8409896a906264e4c2c87"
        }
      });

        const view = new MapView({
          map: webmap,
          container: "viewDiv" // Div element
        });

const scalebar = new ScaleBar({
        view: view
      });

      view.ui.add(scalebar, "bottom-left");        

        var parcelExtent = response.features[0].geometry.extent.clone().expand(0.5);
view.goTo(parcelExtent);
        
        
      });
    &amp;lt;/script&amp;gt;

  &amp;lt;/head&amp;gt;
  &amp;lt;body&amp;gt;
    &amp;lt;div id="viewDiv"&amp;gt;&amp;lt;/div&amp;gt;
  &amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;thanks for any assistance&lt;/P&gt;</description>
      <pubDate>Sun, 07 Nov 2021 15:47:37 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114757#M75188</guid>
      <dc:creator>AwesomeEvan</dc:creator>
      <dc:date>2021-11-07T15:47:37Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114833#M75190</link>
      <description>&lt;P&gt;Hey,&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/338717"&gt;@AwesomeEvan&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. Add the Layer to map while using a definitionExpression&lt;BR /&gt;2. Wait for the LayerView and use the queryExtent Function&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.whenLayerView(layer).then(function(layerView) {
              layerView.watch("updating", function(val) {
                if (!val) {
                  layerView.queryExtent().then(function(response) {
                  view.goTo(response.extent);
                  });
                }
              });
            });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 11:09:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114833#M75190</guid>
      <dc:creator>MichaelBoschert</dc:creator>
      <dc:date>2021-11-08T11:09:19Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114930#M75195</link>
      <description>&lt;P&gt;Is your response geometry a point? The goTo method won't zoom to its extent, since a point doesn't have an extent. You'll have to set the scale for the zoom.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.goTo({
  target: geometry,
  scale: yourScale,
});&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 08 Nov 2021 16:38:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114930#M75195</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2021-11-08T16:38:25Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114935#M75196</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/2839"&gt;@KenBuja&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;no, my response is a area...&lt;/P&gt;&lt;P&gt;Thanks for the supplement.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 16:43:10 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1114935#M75196</guid>
      <dc:creator>MichaelBoschert</dc:creator>
      <dc:date>2021-11-08T16:43:10Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1115002#M75199</link>
      <description>&lt;P&gt;So, I had this solution previously, however there is then only the one layer on the map...&lt;/P&gt;&lt;P&gt;The reason I'm trying to add the whole map is because I want all the layers and stylings from it. Then zoom to the one feature in the specific layer using the url parameter value.&lt;/P&gt;&lt;P&gt;Any suggestions for this setup?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise, I can just add the other layers to the map as well, but then styling them also just seems like way more effort than if I would just query and zoom on an existing layer in the map.&lt;/P&gt;</description>
      <pubDate>Mon, 08 Nov 2021 19:31:25 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1115002#M75199</guid>
      <dc:creator>AwesomeEvan</dc:creator>
      <dc:date>2021-11-08T19:31:25Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1115184#M75204</link>
      <description>&lt;P&gt;Why don't you use the map and additionally add the layer? After zooming in or any other action just&amp;nbsp; remove the layer again.&lt;/P&gt;</description>
      <pubDate>Tue, 09 Nov 2021 07:20:30 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1115184#M75204</guid>
      <dc:creator>MichaelBoschert</dc:creator>
      <dc:date>2021-11-09T07:20:30Z</dc:date>
    </item>
    <item>
      <title>Re: load map and 'goto' specific feature (polyline)</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1116429#M75268</link>
      <description>&lt;P&gt;Awesome that was enough advice to get me there... here's what worked for me... it adds the layer to the map, zooms to it, then removes it... which also creates a better user experience because it doesn't snap back the map everytime you try to pan or zoom away...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;      require(["esri/config","esri/Map","esri/WebMap", "esri/views/MapView","esri/layers/FeatureLayer","esri/widgets/ScaleBar","esri/widgets/Legend"], function (esriConfig,Map,WebMap, MapView, FeatureLayer, ScaleBar, Legend) {
        esriConfig.apiKey = "YOUR_KEY_HERE";

        const webmap = new WebMap({
          portalItem: {
            id: "4170f5e65bd8409896a906264e4c2c87"
          }        
        });
      

        const view = new MapView({
          map: webmap,
          container: "viewDiv" // Div element
        });


        const layer = new FeatureLayer({
          // URL to the service
          url: "https://services3.arcgis.com/pCmV4YWmyIH9CmGq/ArcGIS/rest/services/Crossing_Guards_VIEW/FeatureServer/0",
          definitionExpression: "OBJECTID = " + getUrlParameter('objectid')

        });
        view.map.add(layer);

        const scalebar = new ScaleBar({
        view: view        
        });

        view.ui.add(scalebar, "bottom-left");        

        view.whenLayerView(layer).then(function(layerView){
          layerView.watch("updating", function(val){
            // wait for the layer view to finish updating
            if(!val){
              layerView.queryExtent().then(function(response){
                // go to the extent of all the graphics in the layer view
                view.goTo({target:response.extent, zoom: 17});
                view.map.remove(layer);
              });              
            }
          });
        });


        
      });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 12 Nov 2021 17:46:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/load-map-and-goto-specific-feature-polyline/m-p/1116429#M75268</guid>
      <dc:creator>AwesomeEvan</dc:creator>
      <dc:date>2021-11-12T17:46:33Z</dc:date>
    </item>
  </channel>
</rss>

