<?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: MapView goTo() not working in search.on(&amp;quot;search-complete&amp;quot;) in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267617#M80547</link>
    <description>&lt;P&gt;This actually (view.goTo(view.graphics) is the one of the preferred way to zooming into array of graphics. You don't have to do what you are doing in your first post.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this with 4.24 and the MapView.goTo is working as expected. Here is a simple codepen shows It working:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/wvEmEzw?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/wvEmEzw?editors=1000&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Mar 2023 15:55:14 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2023-03-14T15:55:14Z</dc:date>
    <item>
      <title>MapView goTo() not working in search.on("search-complete")</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267433#M80539</link>
      <description>&lt;P&gt;I am using Arcgis/core version 4.24.&lt;/P&gt;&lt;P&gt;I have the following code inside view.when():&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;    let polylineSymbol = {
      type: "simple-line",  // autocasts as SimpleLineSymbol()
      color: [226, 119, 40],
      width: 4
    };

    function createGraphic(line: any) {
      let polylineGraphic = new Graphic({
        geometry: line,
        symbol: polylineSymbol
      });
      return polylineGraphic;
    }

    function measureLine(vertices: any) {
    
      let line = createLine(vertices);
      let graphic = createGraphic(line);
      view.graphics.add(graphic);
    }

    search.on("search-complete", function(event: any) {

      event.results[0].results.forEach((result: any) =&amp;gt; {
        measureLine(result.feature.geometry.paths)
      })
      // here I am getting just one graphic but to no avail.
      let xmax = view.graphics.getItemAt(0).geometry.extent.xmax;
      let ymax = view.graphics.getItemAt(0).geometry.extent.ymax;
      let xmin = view.graphics.getItemAt(0).geometry.extent.xmin;
      let ymin = view.graphics.getItemAt(0).geometry.extent.ymin;

      const extent = new Extent({
        xmax,
        ymax,
        xmin,
        ymin,
        spatialReference: { wkid: view.spatialReference.wkid }
      })
      view.goTo({
        extent
      }).catch((error) =&amp;gt; {
        console.log('result', error)
      })
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;But for some reason the code above does not work. Any suggestion on why the goTo() does not zoom into the extent?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 08:45:38 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267433#M80539</guid>
      <dc:creator>PL1</dc:creator>
      <dc:date>2023-03-14T08:45:38Z</dc:date>
    </item>
    <item>
      <title>Re: MapView goTo() not working in search.on("search-complete")</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267449#M80541</link>
      <description>&lt;P&gt;I changed the code so that I use&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.goTo(view.graphics);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But goTo() zooms to the first search result. This is not wanted. I would like to zoom on all of the graphics, instead of the first one.&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 09:43:05 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267449#M80541</guid>
      <dc:creator>PL1</dc:creator>
      <dc:date>2023-03-14T09:43:05Z</dc:date>
    </item>
    <item>
      <title>Re: MapView goTo() not working in search.on("search-complete")</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267617#M80547</link>
      <description>&lt;P&gt;This actually (view.goTo(view.graphics) is the one of the preferred way to zooming into array of graphics. You don't have to do what you are doing in your first post.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tested this with 4.24 and the MapView.goTo is working as expected. Here is a simple codepen shows It working:&amp;nbsp;&lt;A href="https://codepen.io/U_B_U/pen/wvEmEzw?editors=1000" target="_blank"&gt;https://codepen.io/U_B_U/pen/wvEmEzw?editors=1000&amp;nbsp;&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Mar 2023 15:55:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267617#M80547</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-03-14T15:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: MapView goTo() not working in search.on("search-complete")</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267893#M80565</link>
      <description>&lt;P&gt;Hello, and thank you for replying to my question!&lt;/P&gt;&lt;P&gt;I actually solved the problem by this way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;  let polylineSymbol = {
    type: "simple-line",  // autocasts as SimpleLineSymbol()
    color: COLOR_CYAN,
    width: HIGHLIGHT_WIDTH
  };
  
  reactiveUtils.once(() =&amp;gt; featurelayer?.loadStatus === "loaded")
    .then(async () =&amp;gt; {
      addToSearchSources(featurelayer) // function that adds the layer to sources
      const result = await search.search(searchParam);
      const graphics = result.results[0].results.map((res: any) =&amp;gt; {
        res.feature.symbol = polylineSymbol;
        return res.feature;
      });
      graphicsLayer.addMany(graphics);
      view.map.add(graphicsLayer);
      view.goTo(graphics);
    });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also set the Search widget's autoSelect to false.&lt;/P&gt;</description>
      <pubDate>Wed, 15 Mar 2023 06:19:43 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/mapview-goto-not-working-in-search-on-quot-search/m-p/1267893#M80565</guid>
      <dc:creator>PL1</dc:creator>
      <dc:date>2023-03-15T06:19:43Z</dc:date>
    </item>
  </channel>
</rss>

