<?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: issue with mapHandler within a function in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331449#M8422</link>
    <description>&lt;P&gt;Jeffry:&lt;/P&gt;&lt;P&gt;modified the get-map-coordinates-function program, but still getting the same issue here&lt;/P&gt;&lt;P&gt;activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when uncomment the original code and debug, any time i hover over the map, it goes to this code, but not when i use the useEffect function, any help will be greatly appreciated&lt;/P&gt;&lt;P&gt;Pedro&lt;/P&gt;</description>
    <pubDate>Fri, 22 Sep 2023 13:56:28 GMT</pubDate>
    <dc:creator>PedroSalazar01</dc:creator>
    <dc:date>2023-09-22T13:56:28Z</dc:date>
    <item>
      <title>issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331274#M8412</link>
      <description>&lt;P&gt;&lt;FONT size="5"&gt;Can some one see why I can not go past this line of code&lt;/FONT&gt;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;handler&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;jmv&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;JimuMapView&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;for some reason when running the program or debugging it does not go past there&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;please see whole program below&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;-----------------------------------------------------------------------------&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;React&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;AllWidgetProps&lt;/SPAN&gt;&lt;SPAN&gt; } &lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;'jimu-core'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;MapViewManager&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;JimuMapViewComponent&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;type&lt;/SPAN&gt; &lt;SPAN&gt;JimuMapView&lt;/SPAN&gt;&lt;SPAN&gt; } &lt;/SPAN&gt;&lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;'jimu-arcgis'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;import&lt;/SPAN&gt; &lt;SPAN&gt;reactiveUtils&lt;/SPAN&gt; &lt;SPAN&gt;from&lt;/SPAN&gt; &lt;SPAN&gt;'esri/core/reactiveUtils'&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;useEffect&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;useState&lt;/SPAN&gt;&lt;SPAN&gt; } &lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;React&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;STRONG&gt;let handler&lt;/STRONG&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;Widget&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;:&lt;/SPAN&gt; &lt;SPAN&gt;AllWidgetProps&lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;any&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;) &lt;/SPAN&gt;&lt;SPAN&gt;=&amp;gt;&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;viewManager&lt;/SPAN&gt; &lt;SPAN&gt;=&lt;/SPAN&gt; &lt;SPAN&gt;MapViewManager&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;getInstance&lt;/SPAN&gt;&lt;SPAN&gt;()&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;const&lt;/SPAN&gt; &lt;SPAN&gt;mapView&lt;/S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bsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;STRONG&gt;handler = (jmv: JimuMapView) =&amp;gt; {&lt;/STRONG&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;alert&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'test'&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;if&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;SPAN&gt;jmv&lt;/SPAN&gt;&lt;SPAN&gt;) { &lt;/SPAN&gt;&lt;SPAN&gt;alert&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Event Handler ready'&lt;/SPAN&gt;&lt;SPAN&gt;) } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt;&lt;SPAN&gt; { &lt;/SPAN&gt;&lt;SPAN&gt;alert&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Not Ready'&lt;/SPAN&gt;&lt;SPAN&gt;) }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; }&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; } &lt;/SPAN&gt;&lt;SPAN&gt;else&lt;/SPAN&gt; &lt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nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;return&lt;/SPAN&gt;&lt;SPAN&gt; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;&amp;lt;&lt;/SPAN&gt;&lt;SPAN&gt;div&lt;/SPAN&gt; &lt;SPAN&gt;className&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;"widget-starter jimu-widget"&lt;/SPAN&gt;&lt;SPAN&gt;&amp;gt;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;{&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;useMapWidgetIds&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;props&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;useMapWidgetIds&lt;/SPAN&gt;&lt;SPAN&gt;.&lt;/SPAN&gt;&lt;SPAN&gt;length&lt;/SPAN&gt;&lt;SPAN&gt; === &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; (&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &am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&gt;Widget&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Thu, 21 Sep 2023 21:08:02 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331274#M8412</guid>
      <dc:creator>PedroSalazar01</dc:creator>
      <dc:date>2023-09-21T21:08:02Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331283#M8413</link>
      <description>&lt;P&gt;When posting code in your questions, please use the "Insert/edit code sample" button&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633" target="_blank"&gt;https://community.esri.com/t5/python-blog/code-formatting-the-community-version/ba-p/1007633#U1007633&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Sep 2023 21:52:40 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331283#M8413</guid>
      <dc:creator>KenBuja</dc:creator>
      <dc:date>2023-09-21T21:52:40Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331389#M8415</link>
      <description>&lt;LI-CODE lang="javascript"&gt;import { React, type AllWidgetProps } from 'jimu-core'
import { MapViewManager, JimuMapViewComponent, type JimuMapView } from 'jimu-arcgis'
import reactiveUtils from 'esri/core/reactiveUtils'

const { useEffect, useState } = React

let handler

const Widget = (props: AllWidgetProps&amp;lt;any&amp;gt;) =&amp;gt; {
  const viewManager = MapViewManager.getInstance()
  const mapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])
  const [jimuMapView, setJimuMapView] = useState&amp;lt;JimuMapView&amp;gt;(mapView)
  const [mapReady, setMapReady] = useState(false)
  useEffect(() =&amp;gt; {
    if (jimuMapView) {
      reactiveUtils
        .whenOnce(() =&amp;gt; jimuMapView.view.ready)
        .then(() =&amp;gt; {
          setMapReady(true)
          alert('map ready')
          if (props.state === 'OPENED') {
            alert('open')
            handler = (jmv: JimuMapView) =&amp;gt; {
              alert('test')
              if (jmv) { alert('Event Handler ready') } else { alert('Not Ready') }
            }
          } else if (props.state === 'CLOSED') {
            alert('closed')
          }
        }
        )
    }
  }, [jimuMapView, props.state])

  return (

    &amp;lt;div className="widget-starter jimu-widget"&amp;gt;
      {
        props.useMapWidgetIds &amp;amp;&amp;amp;
        props.useMapWidgetIds.length === 1 &amp;amp;&amp;amp; (
          &amp;lt;JimuMapViewComponent
            useMapWidgetId={props.useMapWidgetIds?.[0]}
            onActiveViewChange={handler}

          /&amp;gt;
        )
      }
      {/* &amp;lt;p&amp;gt;Lat/Lon: {latitude} {longitude} &amp;lt;/p&amp;gt; */}
      &amp;lt;p&amp;gt;&amp;lt;h9&amp;gt;Click on Map to get the coordinates &amp;lt;/h9&amp;gt;&amp;lt;/p&amp;gt;

     &amp;lt;/div&amp;gt;

  )
}

export default Widget&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 11:16:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331389#M8415</guid>
      <dc:creator>PedroSalazar01</dc:creator>
      <dc:date>2023-09-22T11:16:16Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331390#M8416</link>
      <description>&lt;P&gt;Ken:&lt;/P&gt;&lt;P&gt;Thanks for the tip&lt;/P&gt;&lt;P&gt;what do you think the issue is with this code?&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 11:17:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331390#M8416</guid>
      <dc:creator>PedroSalazar01</dc:creator>
      <dc:date>2023-09-22T11:17:28Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331422#M8420</link>
      <description>&lt;P&gt;You have defined the handler function, but you never actually call handler(). So you will not see the alerts, within the function. onActiveViewChange is called automatically when the map is changed (Not elements within the map, the entire map object.).&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 12:42:21 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331422#M8420</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-09-22T12:42:21Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331445#M8421</link>
      <description>&lt;LI-CODE lang="c"&gt;/* eslint-disable no-prototype-builtins */
/** @jsx jsx */
import { type AllWidgetProps, jsx } from 'jimu-core'
import { useEffect, useState } from 'react'
import { type IMConfig } from '../config'
import { MapViewManager, type JimuMapView, JimuMapViewComponent } from 'jimu-arcgis'
import reactiveUtils from 'esri/core/reactiveUtils'

import type Point from 'esri/geometry/Point'

import defaultMessages from './translations/default'
//const { useEffect, useState } = React

let activeViewChangeHandler

export default function (props: AllWidgetProps&amp;lt;IMConfig&amp;gt;) {
  const [latitude, setLatitude] = useState&amp;lt;string&amp;gt;('')
  const [longitude, setLongitude] = useState&amp;lt;string&amp;gt;('')
  const [zoom, setZoom] = useState&amp;lt;number&amp;gt;(0)
  const [scale, setScale] = useState&amp;lt;number&amp;gt;(0)
  const [mapViewReady, setMapViewReady] = useState&amp;lt;boolean&amp;gt;(false)
  const viewManager = MapViewManager.getInstance()
  const mapView = viewManager.getJimuMapViewById(viewManager.getAllJimuMapViewIds()[0])
  const [jimuMapView, setJimuMapView] = useState&amp;lt;JimuMapView&amp;gt;(mapView)
  const [mapReady, setMapReady] = useState(false)

  useEffect(() =&amp;gt; {
    if (jimuMapView) {
      reactiveUtils
        .whenOnce(() =&amp;gt; jimuMapView.view.ready)
        .then(() =&amp;gt; {
          setMapReady(true)
          alert('map ready')
          if (props.state === 'OPENED') {
            alert('open')
            activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {
              alert('open2')
              if (jmv) {
                // When the extent moves, update the state with all the updated values.
                jmv.view.watch('extent', evt =&amp;gt; {
                  setLatitude(jmv.view.center.latitude.toFixed(3))
                  setLongitude(jmv.view.center.longitude.toFixed(3))
                  setScale(Math.round(jmv.view.scale * 1) / 1)
                  setZoom(jmv.view.zoom)

                  // this is set to false initially, then once we have the first set of data (and all subsequent) it's set
                  // to true, so that we can hide the text until everything is ready:
                  setMapViewReady(true)
                })

                // When the pointer moves, take the pointer location and create a Point
                // Geometry out of it (`view.toMap(...)`), then update the state.
                jmv.view.on('pointer-move', evt =&amp;gt; {
                  const point: Point = jmv.view.toMap({
                    x: evt.x,
                    y: evt.y
                  })
                  setLatitude(point.latitude.toFixed(3))
                  setLongitude(point.longitude.toFixed(3))
                  setScale(Math.round(jmv.view.scale * 1) / 1)
                  setZoom(jmv.view.zoom)
                  setMapViewReady(true)
                })
              }
            }
          } else if (props.state === 'CLOSED') {
            alert('closed')
          }
        }
        )
    }
  }, [jimuMapView, props.state])

  // activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {
  //   if (jmv) {
  //     // When the extent moves, update the state with all the updated values.
  //     jmv.view.watch('extent', evt =&amp;gt; {
  //       setLatitude(jmv.view.center.latitude.toFixed(3))
  //       setLongitude(jmv.view.center.longitude.toFixed(3))
  //       setScale(Math.round(jmv.view.scale * 1) / 1)
  //       setZoom(jmv.view.zoom)

  //       // this is set to false initially, then once we have the first set of data (and all subsequent) it's set
  //       // to true, so that we can hide the text until everything is ready:
  //       setMapViewReady(true)
  //     })

  //     // When the pointer moves, take the pointer location and create a Point
  //     // Geometry out of it (`view.toMap(...)`), then update the state.
  //     jmv.view.on('pointer-move', evt =&amp;gt; {
  //       const point: Point = jmv.view.toMap({
  //         x: evt.x,
  //         y: evt.y
  //       })
  //       setLatitude(point.latitude.toFixed(3))
  //       setLongitude(point.longitude.toFixed(3))
  //       setScale(Math.round(jmv.view.scale * 1) / 1)
  //       setZoom(jmv.view.zoom)
  //       setMapViewReady(true)
  //     })
  //   }
  // }

  const sections = []

  sections.push(
    &amp;lt;span&amp;gt;
      {defaultMessages.latLon} {latitude} {longitude}
    &amp;lt;/span&amp;gt;
  )

  if (props.config.showZoom) {
    sections.push(&amp;lt;span&amp;gt;Zoom {zoom.toFixed(0)}&amp;lt;/span&amp;gt;)
  }

  if (props.config.showScale) {
    sections.push(&amp;lt;span&amp;gt;Scale 1:{scale}&amp;lt;/span&amp;gt;)
  }

  // We have 1, 2, or 3 JSX Elements in our array, we want to join them
  // with " | " between them. You cannot use `sections.join(" | ")`, sadly.
  // So we use array.reduce(...) to return an array of JSX elements.
  const allSections = sections.reduce((previousValue, currentValue) =&amp;gt; {
    return previousValue === null
      ? [currentValue]
      : [...previousValue, ' | ', currentValue]
  }, null)

  return (
    &amp;lt;div className="widget-get-map-coordinates jimu-widget m-2"&amp;gt;
      {props.hasOwnProperty('useMapWidgetIds') &amp;amp;&amp;amp;
        props.useMapWidgetIds &amp;amp;&amp;amp;
        props.useMapWidgetIds.length === 1 &amp;amp;&amp;amp; (
          &amp;lt;JimuMapViewComponent
            useMapWidgetId={props.useMapWidgetIds?.[0]}
            onActiveViewChange={activeViewChangeHandler}
          /&amp;gt;
      )}

      {/* Only show the data once the MapView is ready */}
      &amp;lt;p&amp;gt;{mapViewReady ? allSections : defaultMessages.latLonWillBeHere}&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
  )
}&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 22 Sep 2023 13:52:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331445#M8421</guid>
      <dc:creator>PedroSalazar01</dc:creator>
      <dc:date>2023-09-22T13:52:48Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331449#M8422</link>
      <description>&lt;P&gt;Jeffry:&lt;/P&gt;&lt;P&gt;modified the get-map-coordinates-function program, but still getting the same issue here&lt;/P&gt;&lt;P&gt;activeViewChangeHandler = (jmv: JimuMapView) =&amp;gt; {&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;when uncomment the original code and debug, any time i hover over the map, it goes to this code, but not when i use the useEffect function, any help will be greatly appreciated&lt;/P&gt;&lt;P&gt;Pedro&lt;/P&gt;</description>
      <pubDate>Fri, 22 Sep 2023 13:56:28 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331449#M8422</guid>
      <dc:creator>PedroSalazar01</dc:creator>
      <dc:date>2023-09-22T13:56:28Z</dc:date>
    </item>
    <item>
      <title>Re: issue with mapHandler within a function</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331475#M8424</link>
      <description>&lt;P&gt;activeViewChangeHandler should not be defined within the useEffect function and should only be used for necessary effects when the map changes, usually just redefining the mapView. If your widget does not work with multiple maps, activeViewChangeHandler will never be called. You should delete the definition of activeViewChangeHadler from within the useEffect function, but keep its contents to set up your eventListeners. As written, your widget operates something like this:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Widget loads, useEffect fires, jimuMapView is probably undefined so useEffect and the widget does nothing. activeViewChangeHandler is undefined.&lt;/LI&gt;&lt;LI&gt;jimuMapView becomes defined and useEffect fires again. Wait for jimuMapView.view to become ready.&lt;/LI&gt;&lt;LI&gt;jimuMapView is now ready. If widget.state is OPENED,&amp;nbsp; activeViewChangeHandler now becomes defined.&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Nothing else happens because all of your eventListeners are defined within activeViewChangeHandler and activeViewChangeHandler will only be called if the mapView changes.&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Fri, 22 Sep 2023 14:36:34 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/issue-with-maphandler-within-a-function/m-p/1331475#M8424</guid>
      <dc:creator>JeffreyThompson2</dc:creator>
      <dc:date>2023-09-22T14:36:34Z</dc:date>
    </item>
  </channel>
</rss>

