Creating Features from Map Service Identify

3153
6
05-12-2016 08:07 PM
benberman
Occasional Contributor

Hi everyone,

I have users that request features to be created from when they "Identify" a feature in a map service. I am familiar with leveraging the arcpy FeatureSet class to obtain a json expression and forming features via that method, but from Operations supported in a REST interface. Would there be a way to capture the results of an Identify event when a user selects a feature on a map, and recording those results, so that they can be passed into the FeatureSet?

0 Kudos
6 Replies
BlakeTerhune
MVP Regular Contributor

Are you working in ArcMap or a web app with ArcGIS Javascript API?

0 Kudos
benberman
Occasional Contributor

Webapp. When I enable a popup, and click on a point on the map that falls within the feature layer, the service returns the attributes associated with that feature. I'm trying to come up with a way to do it by leveraging a script, so that the feature and its attributes may be copied to a fgdb feature class.

0 Kudos
BlakeTerhune
MVP Regular Contributor

You might have to make your own geoprocessing service and call it with ArcGIS API for JavaScript

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

first add a button on the pop - up info in order to fire the creation

statsLink = dojo.create("a", {

   "class": "action",

   "innerHTML": "<img id='popupVSinfo' style ='WIDTH: 20px; HEIGHT: 20px' title='Create New Feature' src='images/InfoToolArea.png' >",

   "href": "javascript:void(0);"

  }, dojo.query(".actionList", map.infoWindow.domNode)[0] );

assign a function on this button

dojo.connect(statsLink, "onclick", CreateNewFeature);

inside the function get the selected feature

var graphic = map.infoWindow.getSelectedFeature();

and continue to apply edits on your feature service

FeatureLayer | API Reference | ArcGIS API for JavaScript

require([
 
"esri/layers/FeatureLayer", ...
], function(FeatureLayer, ... ) {
 
var firePerimeterFL = new FeatureLayer( ... );
 
var targetGraphic = firePerimeterFL.getSelectedFeatures()[0].setGeometry(reshapedGeometry);
  firePerimeterFL
.applyEdits(null, [targetGraphic], null);
 
...
});

0 Kudos
benberman
Occasional Contributor

Thanks, but I'm working with a map service, not a feature service. So, would the getSelectedFeature() command still work?

0 Kudos
PanagiotisPapadopoulos
Esri Regular Contributor

pop - up can be enabled to Dynamic and Feature Services.

Try to use it because the selected coming from the infowindow

map.infoWindow.getSelectedFeature();

0 Kudos