<?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: Listen to map selection without selecting a data source in ArcGIS Experience Builder Questions</title>
    <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-map-selection-without-selecting-a-data/m-p/1549072#M15474</link>
    <description>&lt;P&gt;If you are doing this with a custom widget, there are some things you can do&lt;BR /&gt;&lt;BR /&gt;To get a map point something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;handleMapClick = async (event) =&amp;gt; {
    if (this.state.mapSelectionActive) { 
	  // mapSelectionActive is a boolean indicating whether the map is in 'selection' mode or not
      // Query the map point to find various parts
      console.log('Map Click Event:', event)
      const mapPoint: Point = event.mapPoint
      this.selectMapPoint(mapPoint)
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Once you have the mapPoint, you can then do the query for data in your selectMapPoint function.&lt;BR /&gt;&lt;BR /&gt;Depending on your setup the querying of an individual layer could be trivial, or more complex.&lt;BR /&gt;&lt;BR /&gt;But you could then process that map point to say do an intersect query something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;selectMapPoint = async (mapPoint: __esri.Point): Promise&amp;lt;void&amp;gt; =&amp;gt; {
  console.log('selectMapPoint: ', mapPoint)

  // let's say its useDataSource index # 4 we want 
  var useDataSourceIndex = 4; 

  try {
    const dataSource = this.props.useDataSources[useDataSourceIndex]
    const dataSourceId = dataSource.dataSourceId
    const dsParcels: FeatureLayerDataSource = DataSourceManager.getInstance().getDataSource(dataSourceId) as FeatureLayerDataSource
    const queryUrl = dsParcels.url

    if (!queryUrl) {
      throw new Error('Query URL is not defined')
    }

    // Note parcelQueryService is an object with an executePointQuery method which takes the
    // queryUrl inferred from useDataSources via DataSourceManager, the mappoint, 
    // and then sets up the actual query and returns the results asynchronously
    // Note that this suggests a mappoint, if you needed to use geometry pulled from a
    // feature, the method might be strucftured differently
    const result = await this.parcelQueryService.executePointQuery(queryUrl, mapPoint)
	
    // in theory from here you can use the result for that layer how every you want.
    // note if you need more than one layer queried, then you have to do the other queries Perhaps in a foreach and collect them into a results field to then be able to use

    this.setState({ queryResults: result }) // Set the query Result into state     
    } catch (error) {
    console.error('Error in selectMapPoint:', error)
    } finally {
    this.setState({ isLoadingParcelSelection: false }) // Stop loading
    }
  })
}
&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;You can find more information about queries here on the site, but this one has some examples of queries:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/tutorials/query-a-feature-layer-sql/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/tutorials/query-a-feature-layer-sql/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2024 15:19:13 GMT</pubDate>
    <dc:creator>TimWestern</dc:creator>
    <dc:date>2024-10-16T15:19:13Z</dc:date>
    <item>
      <title>Listen to map selection without selecting a data source</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-map-selection-without-selecting-a-data/m-p/1545578#M15234</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I'm starting a new widget and wondering if I can listen to map selection without selecting a data source. I only want to get selected features from specific and pre-defined layers. I was expecting to get to the map view, iterate through the layers, find the ones I want and get the selected features from each one. I did it previously on WAB, and now I'm trying to do the same in ExB.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2024 13:49:41 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-map-selection-without-selecting-a-data/m-p/1545578#M15234</guid>
      <dc:creator>инструкции</dc:creator>
      <dc:date>2024-10-04T13:49:41Z</dc:date>
    </item>
    <item>
      <title>Re: Listen to map selection without selecting a data source</title>
      <link>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-map-selection-without-selecting-a-data/m-p/1549072#M15474</link>
      <description>&lt;P&gt;If you are doing this with a custom widget, there are some things you can do&lt;BR /&gt;&lt;BR /&gt;To get a map point something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;handleMapClick = async (event) =&amp;gt; {
    if (this.state.mapSelectionActive) { 
	  // mapSelectionActive is a boolean indicating whether the map is in 'selection' mode or not
      // Query the map point to find various parts
      console.log('Map Click Event:', event)
      const mapPoint: Point = event.mapPoint
      this.selectMapPoint(mapPoint)
    }
  }&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Once you have the mapPoint, you can then do the query for data in your selectMapPoint function.&lt;BR /&gt;&lt;BR /&gt;Depending on your setup the querying of an individual layer could be trivial, or more complex.&lt;BR /&gt;&lt;BR /&gt;But you could then process that map point to say do an intersect query something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;selectMapPoint = async (mapPoint: __esri.Point): Promise&amp;lt;void&amp;gt; =&amp;gt; {
  console.log('selectMapPoint: ', mapPoint)

  // let's say its useDataSource index # 4 we want 
  var useDataSourceIndex = 4; 

  try {
    const dataSource = this.props.useDataSources[useDataSourceIndex]
    const dataSourceId = dataSource.dataSourceId
    const dsParcels: FeatureLayerDataSource = DataSourceManager.getInstance().getDataSource(dataSourceId) as FeatureLayerDataSource
    const queryUrl = dsParcels.url

    if (!queryUrl) {
      throw new Error('Query URL is not defined')
    }

    // Note parcelQueryService is an object with an executePointQuery method which takes the
    // queryUrl inferred from useDataSources via DataSourceManager, the mappoint, 
    // and then sets up the actual query and returns the results asynchronously
    // Note that this suggests a mappoint, if you needed to use geometry pulled from a
    // feature, the method might be strucftured differently
    const result = await this.parcelQueryService.executePointQuery(queryUrl, mapPoint)
	
    // in theory from here you can use the result for that layer how every you want.
    // note if you need more than one layer queried, then you have to do the other queries Perhaps in a foreach and collect them into a results field to then be able to use

    this.setState({ queryResults: result }) // Set the query Result into state     
    } catch (error) {
    console.error('Error in selectMapPoint:', error)
    } finally {
    this.setState({ isLoadingParcelSelection: false }) // Stop loading
    }
  })
}
&lt;/LI-CODE&gt;&lt;P&gt;&lt;BR /&gt;&lt;BR /&gt;You can find more information about queries here on the site, but this one has some examples of queries:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/tutorials/query-a-feature-layer-sql/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/tutorials/query-a-feature-layer-sql/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Hope this helps.&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 15:19:13 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-experience-builder-questions/listen-to-map-selection-without-selecting-a-data/m-p/1549072#M15474</guid>
      <dc:creator>TimWestern</dc:creator>
      <dc:date>2024-10-16T15:19:13Z</dc:date>
    </item>
  </channel>
</rss>

