Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

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";
});
share|improve this answer
    
thanks for the answer. any chance you have a fiddle that would show this? –  Craig Apr 11 '13 at 12:47
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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