<?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 Map component goTo method troubles in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583113#M86487</link>
    <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the Map Component in a Vite-React-Typescript app.&amp;nbsp; I would like to change the zoom level when the user changes visible layers.&amp;nbsp; However, I get&amp;nbsp;&lt;SPAN&gt;Error:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;map.goTo is not a function.&amp;nbsp; How do I use the beloved goTo with the new Map Component?&amp;nbsp; Also, I would love to provide a center to the goTo but I can't seem to find any spatial information when I log the map and look at the json.&amp;nbsp; I just want to zoom in or out on the current center.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const [map, setMap] = useState(null)

  useEffect(() =&amp;gt; {
    if (map) {
      if (zoom) {
        console.log('checking zoom', zoom, map)
        map.goTo({ zoom })
      } else if (Object.keys(extent).length &amp;gt; 0) {
        map.extent = extent
      }

    }
      
  }, [map, extent, zoom])
...
&amp;lt;ArcgisMap
  basemap={'gray-vector'}
  extent={extent}
  popup={{ dockEnabled: true,
    dockOptions: {
      position: "top-right",
      breakpoint: false
    }} as any}
  onArcgisViewReadyChange={(event: any) =&amp;gt; {
    setMap(event.target.map)
  }}
  &amp;gt;&amp;lt;/ArcgisMap&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 07 Feb 2025 14:40:31 GMT</pubDate>
    <dc:creator>MichelleStuart</dc:creator>
    <dc:date>2025-02-07T14:40:31Z</dc:date>
    <item>
      <title>Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583113#M86487</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I am using the Map Component in a Vite-React-Typescript app.&amp;nbsp; I would like to change the zoom level when the user changes visible layers.&amp;nbsp; However, I get&amp;nbsp;&lt;SPAN&gt;Error:&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;map.goTo is not a function.&amp;nbsp; How do I use the beloved goTo with the new Map Component?&amp;nbsp; Also, I would love to provide a center to the goTo but I can't seem to find any spatial information when I log the map and look at the json.&amp;nbsp; I just want to zoom in or out on the current center.&lt;/SPAN&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const [map, setMap] = useState(null)

  useEffect(() =&amp;gt; {
    if (map) {
      if (zoom) {
        console.log('checking zoom', zoom, map)
        map.goTo({ zoom })
      } else if (Object.keys(extent).length &amp;gt; 0) {
        map.extent = extent
      }

    }
      
  }, [map, extent, zoom])
...
&amp;lt;ArcgisMap
  basemap={'gray-vector'}
  extent={extent}
  popup={{ dockEnabled: true,
    dockOptions: {
      position: "top-right",
      breakpoint: false
    }} as any}
  onArcgisViewReadyChange={(event: any) =&amp;gt; {
    setMap(event.target.map)
  }}
  &amp;gt;&amp;lt;/ArcgisMap&amp;gt;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 14:40:31 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583113#M86487</guid>
      <dc:creator>MichelleStuart</dc:creator>
      <dc:date>2025-02-07T14:40:31Z</dc:date>
    </item>
    <item>
      <title>Re: Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583145#M86490</link>
      <description>&lt;P&gt;you need to access the view not the map in the callback:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;onarcgisViewReadyChange={(event) =&amp;gt; {
  console.debug('onArcgisViewReadyChange', event.target.view);
}}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 15:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583145#M86490</guid>
      <dc:creator>JonathanDawe3</dc:creator>
      <dc:date>2025-02-07T15:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583148#M86491</link>
      <description>&lt;P&gt;Thank you Jonathan!&lt;/P&gt;&lt;P&gt;Where do you find this stuff out?&amp;nbsp; I did not see it in the docs&amp;nbsp; to demo at&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/references/map-components/?path=/docs/component-reference-map--docs" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/references/map-components/?path=/docs/component-reference-map--docs&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 15:35:58 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583148#M86491</guid>
      <dc:creator>MichelleStuart</dc:creator>
      <dc:date>2025-02-07T15:35:58Z</dc:date>
    </item>
    <item>
      <title>Re: Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583153#M86492</link>
      <description>&lt;P&gt;It was a bit through trial and error to be honest - I agree the documentation is sparse for linking between the map components library and the ArcGIS JS API.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I consoled out the event.target, and then just recognised which bit was the MapView. Once I had that I just used the ArcGIS JS docs:&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;In terms of your question regarding the goto function, you should be able to set a center and zoom.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;view.goTo({
  center: [-126, 49],
  zoom: 10
})&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 15:50:42 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583153#M86492</guid>
      <dc:creator>JonathanDawe3</dc:creator>
      <dc:date>2025-02-07T15:50:42Z</dc:date>
    </item>
    <item>
      <title>Re: Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583291#M86497</link>
      <description>&lt;P&gt;There's a goTo method on the map component. You can use a useRef to access the component and it's methods.&lt;/P&gt;</description>
      <pubDate>Fri, 07 Feb 2025 20:35:11 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583291#M86497</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2025-02-07T20:35:11Z</dc:date>
    </item>
    <item>
      <title>Re: Map component goTo method troubles</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583571#M86507</link>
      <description>&lt;P&gt;Thank you so much for your reply, Rene.&amp;nbsp; I didn't realize I could access the view from the event because all the examples I found online only used the `event.target.map`.&amp;nbsp; Hopefully, the demo in the docs will be updated soon to show the key uses that will help us transition to components.&lt;/P&gt;</description>
      <pubDate>Mon, 10 Feb 2025 13:33:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/map-component-goto-method-troubles/m-p/1583571#M86507</guid>
      <dc:creator>MichelleStuart</dc:creator>
      <dc:date>2025-02-10T13:33:32Z</dc:date>
    </item>
  </channel>
</rss>

