Select to view content in your preferred language

Editor Widget Event for Selected Feature

986
1
Jump to solution
09-26-2012 01:54 PM
MeleKoneya
Frequent Contributor
Are there an Events that I can use to get the selected features being used by the attribute inspector and when features are added to the map?

I am using the editor widget in combination with the Attribute Inspector.    I have also created a Template picker and used that with the editor widget. 

In my application,  I am editing points, lines, and polygons from a Feature Server using the On Demand Mode.  I have seen examples that show selected features using the On Selection mode, but was not pleased with having to add both the map server and the featureServer layers so I am trying to find another way. 

I would like to be able to start a function that draws a graphic for the point features when they are selected and displayed in the attribute inspector, as well as when the features are first completed.

What I am currently doing is using the "onClick" event and then I get the colleciton of feature layers in the map, loop through each to find those that have a geomtryType of "esriGeometryPoint", and then using the getSelectedFeatures() method to retrieve any features that may be selected.   

This process does not always seem to work that well as the selected features are not always displayed. 

Thanks for any assitance,

Mele
0 Kudos
1 Solution

Accepted Solutions
MeleKoneya
Frequent Contributor
Here is how I solved my problem.    Probably could use a little clean up, but it is working on my application


function featureCreate() {                 for (var x = 0; x < featureLayers.length; x++) {                     var featureLayer = COSMap.prototype.featureLayers                     drawSelectedFeature(featureLayer);                     drawNewFeature(featureLayer);                 }             };                           //draws newly added Feature             function drawNewFeature(layer) {                 dojo.connect(layer, "onEditsComplete", function (addResults, updateResults, deleteResults) {                     dojo.forEach(addResults, function (addResult) {                         var query = new esri.tasks.Query();                         query.where = "OBJECTID =" + addResult.objectId;                         var featureSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20,    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,    new dojo.Color([255, 0, 0]), 2),    new dojo.Color([0, 255, 255, 0.25]));                         layer.setSelectionSymbol(featureSelectionSymbol);                         layer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);                     });                 });             };              //Draws Currently selected Feature             function drawSelectedFeature(layer) {                 dojo.connect(layer, "onClick", function (evt) {                     var featureSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20,    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,    new dojo.Color([255, 0, 0]), 2),    new dojo.Color([0, 255, 255, 0.25]));                      layer.setSelectionSymbol(featureSelectionSymbol);                     var query = new esri.tasks.Query();                     query.geometry = evt.mapPoint;                     query.returnGeometry = true;                     query.maxAllowableOffset = 500;                     layer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);                 });             }

View solution in original post

0 Kudos
1 Reply
MeleKoneya
Frequent Contributor
Here is how I solved my problem.    Probably could use a little clean up, but it is working on my application


function featureCreate() {                 for (var x = 0; x < featureLayers.length; x++) {                     var featureLayer = COSMap.prototype.featureLayers                     drawSelectedFeature(featureLayer);                     drawNewFeature(featureLayer);                 }             };                           //draws newly added Feature             function drawNewFeature(layer) {                 dojo.connect(layer, "onEditsComplete", function (addResults, updateResults, deleteResults) {                     dojo.forEach(addResults, function (addResult) {                         var query = new esri.tasks.Query();                         query.where = "OBJECTID =" + addResult.objectId;                         var featureSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20,    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,    new dojo.Color([255, 0, 0]), 2),    new dojo.Color([0, 255, 255, 0.25]));                         layer.setSelectionSymbol(featureSelectionSymbol);                         layer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);                     });                 });             };              //Draws Currently selected Feature             function drawSelectedFeature(layer) {                 dojo.connect(layer, "onClick", function (evt) {                     var featureSelectionSymbol = new esri.symbol.SimpleMarkerSymbol(esri.symbol.SimpleMarkerSymbol.STYLE_SQUARE, 20,    new esri.symbol.SimpleLineSymbol(esri.symbol.SimpleLineSymbol.STYLE_SOLID,    new dojo.Color([255, 0, 0]), 2),    new dojo.Color([0, 255, 255, 0.25]));                      layer.setSelectionSymbol(featureSelectionSymbol);                     var query = new esri.tasks.Query();                     query.geometry = evt.mapPoint;                     query.returnGeometry = true;                     query.maxAllowableOffset = 500;                     layer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW);                 });             }
0 Kudos