<?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 Snapping Enforcement/Confirmation 4.19 in ArcGIS JavaScript Maps SDK Questions</title>
    <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054160#M72870</link>
    <description>&lt;P&gt;Is there a way to test whether a point created with the Sketch or Editor widgets has been placed as a snapped point to a particular feature?&amp;nbsp; The feature and vertex highlighting are very useful, but I'm looking for a way to enforce snapping to a particular feature and notify the user if a point wasn't placed as a snapped point.&lt;/P&gt;</description>
    <pubDate>Tue, 04 May 2021 12:03:45 GMT</pubDate>
    <dc:creator>FrederickPowers</dc:creator>
    <dc:date>2021-05-04T12:03:45Z</dc:date>
    <item>
      <title>Snapping Enforcement/Confirmation 4.19</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054160#M72870</link>
      <description>&lt;P&gt;Is there a way to test whether a point created with the Sketch or Editor widgets has been placed as a snapped point to a particular feature?&amp;nbsp; The feature and vertex highlighting are very useful, but I'm looking for a way to enforce snapping to a particular feature and notify the user if a point wasn't placed as a snapped point.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 12:03:45 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054160#M72870</guid>
      <dc:creator>FrederickPowers</dc:creator>
      <dc:date>2021-05-04T12:03:45Z</dc:date>
    </item>
    <item>
      <title>Re: Snapping Enforcement/Confirmation 4.19</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054311#M72886</link>
      <description>&lt;P&gt;You could use various methods of the geometryEngine to validate that geometries intersect or that a vertex matches a point&lt;/P&gt;&lt;P&gt;&lt;A href="https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html" target="_blank"&gt;https://developers.arcgis.com/javascript/latest/api-reference/esri-geometry-geometryEngine.html&lt;/A&gt;&lt;/P&gt;&lt;P&gt;It might require breaking up polygons -&amp;gt; polylines -&amp;gt; points, but should be doable.&lt;/P&gt;</description>
      <pubDate>Tue, 04 May 2021 17:39:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054311#M72886</guid>
      <dc:creator>ReneRubalcava</dc:creator>
      <dc:date>2021-05-04T17:39:23Z</dc:date>
    </item>
    <item>
      <title>Re: Snapping Enforcement/Confirmation 4.19</title>
      <link>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054585#M72902</link>
      <description>&lt;P&gt;Thank you for the guidance.&amp;nbsp; This case required validating snapping a point to a line, so the steps that were implemented were:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Do a spatial query on the feature layer with a buffer from the graphic geometry.&lt;/LI&gt;&lt;LI&gt;If there are no geometries returned the point wasn't snapped.&lt;/LI&gt;&lt;LI&gt;If at least one geometry was returned, test the graphic geometry for intersection for each feature.&lt;/LI&gt;&lt;LI&gt;If one of the features returned intersects the graphic geometry the point was snapped.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;The code for this is as follows. It watches the Sketch for "on creation complete", and passes the geometry to a function that does the spatial query and tests the intersection of any features returned.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;sketch.on("create", function (event) {
  if (event.state === "complete") {
    let pointBuffer = geometryEngine.buffer(event.graphic.geometry, 1);
    queryFeaturelayer(pointBuffer);
  }
});

function queryFeaturelayer(geometry) {
  const featureQuery = {
    spatialRelationship: "intersects",
    geometry: geometry,
    outFields: ['*'], 
    returnGeometry: true
  };

  featureLayer.queryFeatures(featureQuery)
    .then((results) =&amp;gt; {
      if ( results.features.length === 0 ) {
        alert("Point not snapped");
      }
      else {
        let snapped = false;
        results.features.forEach(feature =&amp;gt; {
          if (geometryEngine.intersects(geometry.centroid, feature.geometry)){
            snapped = true;
          }
        });

        if ( snapped ) {
          alert("Point snapped");
        } else {
          alert("Point not snapped");
        }
      }
    }).catch((error) =&amp;gt; {
      console.log(error);
    });
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 05 May 2021 11:52:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/arcgis-javascript-maps-sdk-questions/snapping-enforcement-confirmation-4-19/m-p/1054585#M72902</guid>
      <dc:creator>FrederickPowers</dc:creator>
      <dc:date>2021-05-05T11:52:23Z</dc:date>
    </item>
  </channel>
</rss>

