<?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: View on event while actively drawing sketch polygon. in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1265146#M80480</link>
    <description>&lt;P&gt;HI there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can listen to S&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#event-create" target="_self"&gt;ketchViewModel.create&lt;/A&gt; event like you are doing. Create event fires when yon start sketching a graphic, while actively sketching it and when you complete sketching the graphic. The event payload returns things like state and the state will be active while you are drawing the graphic. The toolEventInfo returns additional information you can could tap into. Event also returns the graphic that is being drawn. You can keep checking the geometry of this graphic to make sure that it is still acceptable. This sample shows how to check if the polygon is valid while user is updating the geometry. It uses sketchViewModel. Perhaps it will give you some ideas how you can do the same thing while creating a graphic.&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 07 Mar 2023 20:19:03 GMT</pubDate>
    <dc:creator>UndralBatsukh</dc:creator>
    <dc:date>2023-03-07T20:19:03Z</dc:date>
    <item>
      <title>View on event while actively drawing sketch polygon.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1264737#M80466</link>
      <description>&lt;P&gt;I'm looking to&amp;nbsp;restrict the size of a polygon that a user can create with the sketch tool based on current extent. I can calculate the distance between lat and lon, but I will need an event that I can monitor while the polygon is being drawn.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;const sketchLayer = new GraphicsLayer();

sketchViewModel = new SketchViewModel({
  view: view,
  layer: sketchLayer,
  pointSymbol: pointSymbol,
  polylineSymbol: polylineSymbol,
  polygonSymbol: polygonSymbol,
  snappingOptions: {
	enabled: true,	
	featureSources: [{ layer: sketchLayer, enabled: true }],
  },
  mode: 'click',
  defaultCreateOptions: {
	hasZ: false,
	enableScaling: false,
	enableRotation: false,
	toggleToolOnClick: false,
	shapeOperation: 'none',
  },
  updateOnGraphicClick: false,
});


sketchViewModel.on('create', (event) =&amp;gt; {      
  if (event.state === 'complete') { 
   // know if the polygon dimensions are valid size before getting here.
 }
});&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 06 Mar 2023 22:33:44 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1264737#M80466</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2023-03-06T22:33:44Z</dc:date>
    </item>
    <item>
      <title>Re: View on event while actively drawing sketch polygon.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1265146#M80480</link>
      <description>&lt;P&gt;HI there,&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can listen to S&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-widgets-Sketch.html#event-create" target="_self"&gt;ketchViewModel.create&lt;/A&gt; event like you are doing. Create event fires when yon start sketching a graphic, while actively sketching it and when you complete sketching the graphic. The event payload returns things like state and the state will be active while you are drawing the graphic. The toolEventInfo returns additional information you can could tap into. Event also returns the graphic that is being drawn. You can keep checking the geometry of this graphic to make sure that it is still acceptable. This sample shows how to check if the polygon is valid while user is updating the geometry. It uses sketchViewModel. Perhaps it will give you some ideas how you can do the same thing while creating a graphic.&amp;nbsp;&lt;A href="https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/sample-code/sketch-update-validation/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 07 Mar 2023 20:19:03 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1265146#M80480</guid>
      <dc:creator>UndralBatsukh</dc:creator>
      <dc:date>2023-03-07T20:19:03Z</dc:date>
    </item>
    <item>
      <title>Re: View on event while actively drawing sketch polygon.</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1266134#M80504</link>
      <description>&lt;P&gt;Thanks! I can check the size of the sketch, but not sure how to block drawing without destroying the sketch. I found this in community, but I'm not seeing a 'move'. There is a '&lt;SPAN&gt;cursor-update'.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="c"&gt;no 'move'
if (event.toolEventInfo &amp;amp;&amp;amp; event.toolEventInfo.type.includes("move")){
  sketchViewModel.cancel();
}‍‍‍&lt;/LI-CODE&gt;&lt;LI-CODE lang="c"&gt;if(event.state === 'active') {
// console.log(`H ${event.graphic.geometry.extent.height} x W ${event.graphic.geometry.extent.width}`); 
	if(event.graphic.geometry.extent.width &amp;gt; 200) {
	  if (event.toolEventInfo &amp;amp;&amp;amp; event.toolEventInfo.type.includes('cursor-update')) {
     // cancel() completely destroying the sketch.
     // how to just stop drawing the width without killing sketch?
		sketchViewModel.cancel();
	  }
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Mar 2023 18:39:57 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/view-on-event-while-actively-drawing-sketch/m-p/1266134#M80504</guid>
      <dc:creator>GregoryBologna</dc:creator>
      <dc:date>2023-03-09T18:39:57Z</dc:date>
    </item>
  </channel>
</rss>

