<?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 How to set query radius when using keyup event to open popup and fetch features? in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-query-radius-when-using-keyup-event-to/m-p/1193211#M77956</link>
    <description>&lt;P&gt;I'm attempting to set up a keyboard accessible option for users to simulate a "click" on feature(s) on the map and open relevant popup(s). The approach below kind of works, but would work much better if I could figure out how to specify a query radius as well.&lt;/P&gt;&lt;P&gt;Here's how the code is currently set up:&lt;/P&gt;&lt;P&gt;There is an event listener for the keyup event and a target graphic in the center of the map that the user can use to pinpoint the desired feature to get information.&amp;nbsp; The user uses arrow keys and +- to navigate the map so that the desired feature is within the target. If the user hits the "i" key on the keyboard, a popup opens with the location option set to view.center and fetchFeatures to true.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In testing, I've found that it is challenging to get a point or line feature right to the target/center of the map, particularly if zoomed in.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The API mentions FetchFeaturesOptions optional properties that can be used with the fetchFeatures method. I read the following regarding the event property: "&lt;SPAN&gt;The&amp;nbsp;&lt;/SPAN&gt;click&lt;SPAN&gt;&amp;nbsp;event for either the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" target="_blank" rel="noopener"&gt;MapView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html" target="_blank" rel="noopener"&gt;SceneView&lt;/A&gt;&lt;SPAN&gt;. The event can be supplied in order to adjust the query radius depending on the pointer type. For example, touch events query a larger radius." Does anyone know if I can use these options in the code below to set a radius? I'm struggling to figure it out. Any other suggestions on how I can improve this code?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Set up keyboard accessible option for getting information for features on the map

// 1. set focus on the map view to enable keyboard navigation
view.focus();

// 2. add a circle graphic to the center of the map so that the user can pinpoint the feature for which they'd like info
addMapCenterGraphic();

// 3. On keyup, check to see which key the user pressed and respond accordingly

aria.handleMapSelect = function (event) {
    var key = event.which || event.keyCode;
    //if the user hits the i key on the keyboard, simulate a mouse click on the center of the map
    if (key === 73 ) {
        event.stopPropagation();
        
        view.popup.open({
            location: view.center, // location of the click on the view
            fetchFeatures: true // display the content for the selected feature if a popupTemplate is defined.
        });
        view.popup.focus();
      
    } else {
        //if the key is an arrow
        if( key=== 37||key=== 38 || key=== 39 ||key=== 40) {
            // move graphic to the new center point
            mapCenterGraphic.removeAll();
            addMapCenterGraphic();
        }
    }
};

document.addEventListener('keyup', aria.handleMapSelect);&lt;/LI-CODE&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>Mon, 18 Jul 2022 21:58:51 GMT</pubDate>
    <dc:creator>Strahanjen</dc:creator>
    <dc:date>2022-07-18T21:58:51Z</dc:date>
    <item>
      <title>How to set query radius when using keyup event to open popup and fetch features?</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-query-radius-when-using-keyup-event-to/m-p/1193211#M77956</link>
      <description>&lt;P&gt;I'm attempting to set up a keyboard accessible option for users to simulate a "click" on feature(s) on the map and open relevant popup(s). The approach below kind of works, but would work much better if I could figure out how to specify a query radius as well.&lt;/P&gt;&lt;P&gt;Here's how the code is currently set up:&lt;/P&gt;&lt;P&gt;There is an event listener for the keyup event and a target graphic in the center of the map that the user can use to pinpoint the desired feature to get information.&amp;nbsp; The user uses arrow keys and +- to navigate the map so that the desired feature is within the target. If the user hits the "i" key on the keyboard, a popup opens with the location option set to view.center and fetchFeatures to true.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In testing, I've found that it is challenging to get a point or line feature right to the target/center of the map, particularly if zoomed in.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The API mentions FetchFeaturesOptions optional properties that can be used with the fetchFeatures method. I read the following regarding the event property: "&lt;SPAN&gt;The&amp;nbsp;&lt;/SPAN&gt;click&lt;SPAN&gt;&amp;nbsp;event for either the&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-MapView.html" target="_blank" rel="noopener"&gt;MapView&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;or&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-views-SceneView.html" target="_blank" rel="noopener"&gt;SceneView&lt;/A&gt;&lt;SPAN&gt;. The event can be supplied in order to adjust the query radius depending on the pointer type. For example, touch events query a larger radius." Does anyone know if I can use these options in the code below to set a radius? I'm struggling to figure it out. Any other suggestions on how I can improve this code?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;//Set up keyboard accessible option for getting information for features on the map

// 1. set focus on the map view to enable keyboard navigation
view.focus();

// 2. add a circle graphic to the center of the map so that the user can pinpoint the feature for which they'd like info
addMapCenterGraphic();

// 3. On keyup, check to see which key the user pressed and respond accordingly

aria.handleMapSelect = function (event) {
    var key = event.which || event.keyCode;
    //if the user hits the i key on the keyboard, simulate a mouse click on the center of the map
    if (key === 73 ) {
        event.stopPropagation();
        
        view.popup.open({
            location: view.center, // location of the click on the view
            fetchFeatures: true // display the content for the selected feature if a popupTemplate is defined.
        });
        view.popup.focus();
      
    } else {
        //if the key is an arrow
        if( key=== 37||key=== 38 || key=== 39 ||key=== 40) {
            // move graphic to the new center point
            mapCenterGraphic.removeAll();
            addMapCenterGraphic();
        }
    }
};

document.addEventListener('keyup', aria.handleMapSelect);&lt;/LI-CODE&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>Mon, 18 Jul 2022 21:58:51 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/how-to-set-query-radius-when-using-keyup-event-to/m-p/1193211#M77956</guid>
      <dc:creator>Strahanjen</dc:creator>
      <dc:date>2022-07-18T21:58:51Z</dc:date>
    </item>
  </channel>
</rss>

