Select to view content in your preferred language

Editor snapping not recognising  SNAP_MODE_ALWAYS_ON or 'Shared' vertice on polygon

934
3
12-13-2011 05:22 PM
MarkHoyland
Frequent Contributor
I am using the Editor to 'Split' a polygon that has an adjacent polygon.(using Version 2.5 api).

Firstly I have set the Editor's EditTool to have SNAP_MODE_ALWAYS_ON, but I still have to hold the CTRL key for snapping to engage. Am I missing something?

Secondly, snapping does NOT recognised the shared Vertice and I can not snap to it. See attached image.

Any ideas?
Can I turn off Line snapping and only snap to vertice?

Code below is a modified copy from the samples and has extent of the polygon's I am trying to edit.
It also sets the EditTool's properties when the Editor component is created.

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
      xmlns:s="library://ns.adobe.com/flex/spark"
      xmlns:mx="library://ns.adobe.com/flex/mx"
      xmlns:esri="http://www.esri.com/2008/ags"
      initialize="application1_initializeHandler(event)"
      pageTitle="Editor with all toolbar options">
 <!--
 This sample shows you how to use the editor component with a full toolbar.
 -->
 
 <fx:Style>
  @namespace esri "http://www.esri.com/2008/ags";
  
  esri|InfoWindow
  {
   background-color : #FFFFFF;
   border-thickness : 2;
  }
 </fx:Style>
 
 <fx:Script>
  <![CDATA[
   import com.esri.ags.components.supportClasses.CreateOptions;
   import com.esri.ags.tasks.GeometryService;
   import com.esri.ags.tools.DrawTool;
   import com.esri.ags.tools.EditTool;
   
   import mx.events.FlexEvent;
   
   protected function application1_initializeHandler(event:FlexEvent):void
   {
    myEditor.featureLayers = [ fireAreas ];
    var myDrawTypePreferences:CreateOptions = new CreateOptions();
    // change the defauls drawing tool from "point-to-point" to "freehand"
    myDrawTypePreferences.polygonDrawTools = [ DrawTool.POLYGON, DrawTool.POLYLINE, CreateOptions.AUTO_COMPLETE ];
    myEditor.createOptions = myDrawTypePreferences;
   }
   
   protected function myEditor_creationCompleteHandler(event:FlexEvent):void
   {
    var editTool:EditTool = myEditor.editTool;
    editTool.snapMode = EditTool.SNAP_MODE_ALWAYS_ON;
    editTool.allowAddVertices = false;
    editTool.allowDeleteVertices = false;
   }
   
  ]]>
 </fx:Script>
 
 
 <mx:VBox width="100%" height="100%">
  
  <esri:Map id="map" wrapAround180="true">
   <esri:extent>
    <esri:Extent id="sheepfire"
        xmin="14404817" ymin="-3626334" xmax="14991242" ymax="-3224581">
     <esri:SpatialReference wkid="102100"/>
    </esri:Extent>
   </esri:extent>
   <esri:ArcGISTiledMapServiceLayer url="http://server.arcgisonline.com/ArcGIS/rest/services/World_Topo_Map/MapServer"/>
   <esri:FeatureLayer id="fireAreas" mode="snapshot" outFields="*"
          url="http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Fire/Sheep/FeatureServer/2"/>
  </esri:Map>
  <esri:Editor id="myEditor" creationComplete="myEditor_creationCompleteHandler(event)"
      width="100%"
      geometryService="{new GeometryService('http://sampleserver3.arcgisonline.com/ArcGIS/rest/services/Geometry/GeometryServer')}"
      map="{map}"
      toolbarCutVisible="true"
      toolbarMergeVisible="true"
      toolbarReshapeVisible="true"
      toolbarVisible="true" 
      />
 </mx:VBox>
</s:Application>

Tags (2)
0 Kudos
3 Replies
SarthakDatt
Frequent Contributor
Hey Mark,

I am not able to reproduce the 1st issue you reported, its working the way its supposed to work.
You can try maybe setting the snapMode even earlier, like in the application initialize handler.

Regarding the 2nd issue, I am still trying to figure out what exactly the problem is. We try to differentiate b/w vertex snapping and edge(line) snapping by showing a "bolder" cross v/s  a normal cross. Do you see that in your application?

Right now, there is no way to turn off edge snapping and vice-versa.

-- Sarthak
0 Kudos
MarkHoyland
Frequent Contributor
Hi Sarthak,

1. So my code works for you with SNAP_MODE_ALWAYS_ON?
Do you have some tested and working code that you can provide so I can see if it something to do with my set up.

2. I do not get the bold cross on 'shared' vertices where there is a 'T' intersection like in my image. It always wants to snap to the edge and does not find the vertex.
If you use the code I provided, the extents go to the polygons in the image. You can test on those polygons.
0 Kudos
SarthakDatt
Frequent Contributor
Mark,

Yes I tried your code in the attached project and it works fine. You can try it at your end too.
Still looking at the 2nd issue..

-- Sarthak
0 Kudos