<?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: Select by rectangle or by click using ArcGIS JavaScript API in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-by-rectangle-or-by-click-using-arcgis/m-p/1205015#M78390</link>
    <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can set the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#defaultCreateOptions" target="_self"&gt;SkethcViewModel.defaultCreateOptions&lt;/A&gt;.mode to freehand or can set the mode when you call create method:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const sketchViewModel = new SketchViewModel({
  view: view,
  layer: polygonGraphicsLayer,
  defaultCreateOptions: {
    mode: "freehand"
  }
});&lt;/LI-CODE&gt;&lt;P&gt;Or you can do:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;sketchViewModel.create("rectangle", { mode: "freehand" });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both options should work in your case.&lt;/P&gt;</description>
    <pubDate>Mon, 22 Aug 2022 14:56:01 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2022-08-22T14:56:01Z</dc:date>
    <item>
      <title>Select by rectangle or by click using ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-by-rectangle-or-by-click-using-arcgis/m-p/1204947#M78385</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;0&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;I have a small button that has one job, select features on the Map. I am using the SketchViewModel class, to create a rectangle. Then use this rectangle to query features that intersect it. The behaviour is hold mouse, drag, release, we now have a rectangle. This is correct since the user will use the mouse to draw the rectangle that will select the features they want.&lt;/P&gt;&lt;P&gt;The problem I am facing is when the user single clicks on the map once the method create("rectangle") is called. The API default behaviour, is to draw a rectangle, large enough to intersect multiple features from a single click on the map.&lt;/P&gt;&lt;P&gt;This is not the correct behaviour that I am looking for. I looked everywhere through the help, as to change this default size of the rectangle but there is no way to change it so that on click will not draw a large rectangle.&lt;/P&gt;&lt;P&gt;How do I resolve this?&lt;/P&gt;&lt;PRE&gt; &lt;SPAN class=""&gt;// click button handler&lt;/SPAN&gt;
&lt;SPAN class=""&gt;function&lt;/SPAN&gt; &lt;SPAN class=""&gt;sketchViewClicked&lt;/SPAN&gt;(&lt;SPAN class=""&gt;event&lt;/SPAN&gt;) {
   shereSketchModel.&lt;SPAN class=""&gt;create&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"rectangle"&lt;/SPAN&gt;);
}
...
...
...

 shereSketchModel.&lt;SPAN class=""&gt;on&lt;/SPAN&gt;(&lt;SPAN class=""&gt;"create"&lt;/SPAN&gt;, &lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;event&lt;/SPAN&gt;) =&amp;gt;&lt;/SPAN&gt; {
    &lt;SPAN class=""&gt;if&lt;/SPAN&gt; (event.&lt;SPAN class=""&gt;state&lt;/SPAN&gt; === &lt;SPAN class=""&gt;"complete"&lt;/SPAN&gt;) {
      &lt;SPAN class=""&gt;// this polygon will be used to query features that intersect it&lt;/SPAN&gt;
      &lt;SPAN class=""&gt;const&lt;/SPAN&gt; geometries = polygonGraphicsLayer.&lt;SPAN class=""&gt;graphics&lt;/SPAN&gt;.&lt;SPAN class=""&gt;map&lt;/SPAN&gt;(&lt;SPAN class=""&gt;function&lt;/SPAN&gt;(&lt;SPAN class=""&gt;graphic&lt;/SPAN&gt;) {
        &lt;SPAN class=""&gt;return&lt;/SPAN&gt; graphic.&lt;SPAN class=""&gt;geometry&lt;/SPAN&gt;;
      });
      &lt;SPAN class=""&gt;GeometryEngineAsync&lt;/SPAN&gt;.&lt;SPAN class=""&gt;union&lt;/SPAN&gt;(geometries.&lt;SPAN class=""&gt;toArray&lt;/SPAN&gt;()).&lt;SPAN class=""&gt;then&lt;/SPAN&gt;(
        &lt;SPAN class=""&gt;(&lt;SPAN class=""&gt;queryGeometry&lt;/SPAN&gt;) =&amp;gt;&lt;/SPAN&gt; {
          &lt;SPAN class=""&gt;SelectFeatures&lt;/SPAN&gt;(queryGeometry);
         
        }
      );  }
  });&lt;/PRE&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Mon, 22 Aug 2022 12:22:16 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-by-rectangle-or-by-click-using-arcgis/m-p/1204947#M78385</guid>
      <dc:creator>ZaidOdeh</dc:creator>
      <dc:date>2022-08-22T12:22:16Z</dc:date>
    </item>
    <item>
      <title>Re: Select by rectangle or by click using ArcGIS JavaScript API</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-by-rectangle-or-by-click-using-arcgis/m-p/1205015#M78390</link>
      <description>&lt;P&gt;Hi there,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;You can set the &lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch-SketchViewModel.html#defaultCreateOptions" target="_self"&gt;SkethcViewModel.defaultCreateOptions&lt;/A&gt;.mode to freehand or can set the mode when you call create method:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const sketchViewModel = new SketchViewModel({
  view: view,
  layer: polygonGraphicsLayer,
  defaultCreateOptions: {
    mode: "freehand"
  }
});&lt;/LI-CODE&gt;&lt;P&gt;Or you can do:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;sketchViewModel.create("rectangle", { mode: "freehand" });&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both options should work in your case.&lt;/P&gt;</description>
      <pubDate>Mon, 22 Aug 2022 14:56:01 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/select-by-rectangle-or-by-click-using-arcgis/m-p/1205015#M78390</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2022-08-22T14:56:01Z</dc:date>
    </item>
  </channel>
</rss>

