5

I'm looking to build a new application that allows staff to edit a service/layer. They will be inputting new survey benchmark data based on lat/long.

All of the current samples I have seen on the ESRI site show the editing done by clicking a point on a map and then populating the fields in the popup.

My goal would be to input the fields first and then have the app recognize the x,y and draw new point.

This would eliminate the error of the spot being clicked not actually being the correct coordinates.

Also, they will be doing the input at the office, so enabling GPS or similar in the app won't be helpful.

Does anybody know of a sample or way to do this?

4

Basically, set up your own textboxes, select boxes, etc. Put an onclick event handler on the submit button (dojo.connect()). Get the values from the entry boxes. Then use the long/lat and other attributes that you collect, create a geometry and attribute object, create a graphic from them and then send it to your editable feature layer using editableFeatureLayer.applyEdits

//create a graphic
var pt = new esri.geometry.Point(-118.15, 33.80, new esri.SpatialReference({ wkid: 4326 }));
var attr = {"Xcoord":evt.mapPoint.x,"Ycoord":evt.mapPoint.y,"Plant":"Mesa Mint"};
var addGraphic = new esri.Graphic(pt,null,attr,null);

//you can add more attributes to the graphic
var d = new Date();
addGraphic.attributes.Updated_By = loginName;
addGraphic.attributes.Updated_Date = d.getTime();

//Using your editable feature layer add the graphic
editableFeatureLayer.applyEdits([addGraphic], null, null, function (adds, updates, deletes) {
    var query = new esri.tasks.Query();
    query.objectIds = [adds[0].objectId];
    //highlight on the map after adding if you want
    editableFeatureLayer.selectFeatures(query, esri.layers.FeatureLayer.SELECTION_NEW, function () {
        pairedAGSDynamicMapServiceLayer.refresh();
    });
    dojo.byId('infoPane').innerHTML = "Added feature successfully<br />OBJECTID: " + adds[0].objectId + "<br />";
}, 
{   // if errors
    pairedAGSDynamicMapServiceLayer.refresh();
    dojo.byId('infoPane').innerHTML = "Error during add operation";
});
  • thanks for the answer. any chance you have a fiddle that would show this? – Craig Apr 11 '13 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.