AnsweredAssumed Answered

apply edits error

Question asked by abbabharath on Dec 6, 2016

Hi ,


i am unable to edit line feature on map click for the second time below is the code i have used landuselinelayer is line feature, 

landusepointlayer is point feature (for the second time i'm getting following error unable to complete operation)


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
<meta name="viewport" content="initial-scale=1, maximum-scale=1,user-scalable=no">
<link rel="stylesheet" href="">
<link rel="stylesheet" href="">
html, body
height: 100%;
width: 100%;
margin: 0;
padding: 0;
overflow: hidden;

background: #3f3f3f;
color: #fff;
font-family: Tahoma;
font-size: 11px;
height: 18px;
color: #000;
font-family: Tahoma;
font-size: 11px;
font-weight: 200;
border: solid 2px #462d44;
background: #fff;
color: #444;
-moz-border-radius: 4px;
border-radius: 4px;
font-family: sans-serif;
font-size: 1.1em padding-left:20px;
padding: 1px;
border: solid 2px #444;
-moz-border-radius: 4px;
border-radius: 4px;
border: none;
padding: 0;
width: 228px;
border: solid 2px #444;
<script src=""></script>
<script type="text/javascript">
var map;
"dojo/dom", "dojo/on",






"dijit/layout/BorderContainer", "dijit/layout/ContentPane",
"dijit/form/Button", "dojo/domReady!"
], function (
dom, on, Map, ArcGISDynamicMapServiceLayer, Draw, Edit, Graphic, esriConfig, QueryTask, Query, Color, Polyline, Point,
SimpleMarkerSymbol, SimpleLineSymbol, SimpleFillSymbol, CartographicLineSymbol,
arrayUtils, event, lang, parser, registry, Color
) {

// refer to "Using the Proxy Page" for more information: = "/proxy/";

// This service is for development and testing purposes only. We recommend that you create your own geometry service for use within your applications.
esriConfig.defaults.geometryService = new esri.tasks.GeometryService("");

map = new Map("map", {

center: [-83.244, 42.581],
zoom: 15

var executeQueryTask;
var line;
var lineSymbol;

var dynamicMapServiceLayer = new ArcGISDynamicMapServiceLayer("http://localhost:6080/arcgis/rest/services/edit/MapServer");

//initialize query task
var queryTask = new QueryTask("http://localhost:6080/ArcGIS/rest/services/edit/MapServer/20");

//initialize query
var query = new Query();
query.returnGeometry = true;
query.outFields = ["LTP_ID", "OBJECTID"];

symbol = new SimpleMarkerSymbol();
symbol.setColor(new Color([255, 255, 0, 0.5]));

on(dom.byId("execute"), "click", execute);

on(dom.byId("ltext"), "click", ltext);



var landusePointLayer = new FeatureLayer("http://localhost:6080/arcgis/rest/services/edit/FeatureServer/20", {
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]
var landuseLineLayer = new FeatureLayer("http://localhost:6080/arcgis/rest/services/edit/FeatureServer/34", {
mode: FeatureLayer.MODE_SNAPSHOT,
outFields: ["*"]


// map.on("layers-add-result",setupEditor);

map.addLayers([landusePointLayer, landuseLineLayer]);



function execute() {
query.text = dom.byId("stateName").value;
queryTask.execute(query, showResults);

function showResults(featureSet) {

//Performance enhancer - assign featureSet array to a single variable.
var resultFeatures = featureSet.features;

//Loop through each feature returned
for (var i = 0, il = resultFeatures.length; i < il; i++) {
//Get the current feature from the featureSet.
//Feature is a graphic
var graphic = resultFeatures[i];

//Set the infoTemplate.

//Add graphic to the map graphics layer.;

if (graphic.geometry.type === 'point') {

map.centerAndZoom(graphic.geometry, 0.001);


function ltext() {

line = new Polyline(map.spatialReference);
lineSymbol = new CartographicLineSymbol(
new Color([255, 0, 0]), 10,
CartographicLineSymbol.JOIN_MITER, 5

pointSymbol = new SimpleMarkerSymbol().setColor(new Color([255, 0, 0, 0.5]));

dojo.connect(map, "onClick", addPt);


function addPt(e) {

var pathCount = line.paths.length;
// console.log(e.mapPoint.y);
// console.log(e.mapPoint.x);
if (pathCount == 0) {
var point1 = new Point(218966.696, 1173294.233, map.spatialReference);
var point2 = new Point(e.mapPoint.x, e.mapPoint.y, map.spatialReference);

line.addPath([point1, point2]); Graphic(point1, pointSymbol)); Graphic(point2, pointSymbol)); Graphic(line, lineSymbol));

var template = landusePointLayer.templates[0];
var newAttributes = lang.mixin({}, template.prototype.attributes);
var newGraphic = new Graphic(point2, null, newAttributes);
landusePointLayer.applyEdits([newGraphic], null, null);

var template1 = landuseLineLayer.templates[0];
var newAttributes = lang.mixin({}, template1.prototype.attributes);
var newGraphicss = new Graphic(line, null, newAttributes);
landuseLineLayer.applyEdits([newGraphicss], null, null);
else {

var getX = line.paths[pathCount - 1][line.paths[pathCount - 1].length - 1][0],
getY = line.paths[pathCount - 1][line.paths[pathCount - 1].length - 1][1],
mapPointX = e.mapPoint.x, mapPointY = e.mapPoint.y;
var pointS = new Point(getX, getY, map.spatialReference);
var pointD = new Point(mapPointX, mapPointY, map.spatialReference);

line.addPath([pointS, pointD]);

/////////////////////////////////////////////////////////////////////////////////////////////// Graphic(pointS, pointSymbol)); Graphic(pointD, pointSymbol)); Graphic(line, pointSymbol));

var template1 = landusePointLayer.templates[0];
var newAttributes = lang.mixin({}, template1.prototype.attributes);
var newGraphic = new Graphic(pointD, null, newAttributes);
landusePointLayer.applyEdits([newGraphic], null, null);

var template1 = landuseLineLayer.templates[0];
var newAttributessss = lang.mixin({}, template1.prototype.attributes);
var newGraphicss = new Graphic(line, null, newAttributessss);
landuseLineLayer.applyEdits([newGraphicss], null, null);



<body class="claro">
<div style="height: 30px; border: solid 1px; border-color: #e4e4e4; width: 100%;
background: #f0ebff">
<div style="height: 25px; border: solid 1px; border-color: #e4e4e4; width: 100%;
background: #d2d2d2; text-align: center">
<div data-dojo-type="dijit/layout/BorderContainer" data-dojo-props="gutters:true, design:'headline'"
style="width: 100%; height: 100%;">

<div id="map" data-dojo-type="dijit/layout/ContentPane" data-dojo-props="region:'center'">
<div id="rightPane" data-dojo-type="dijit.layout.ContentPane" data-dojo-props="region:'right'">
<span class="lbl">Enter Value :</span>
<input type="text" id="stateName" >
<input id="execute" type="button" value="Get Details">

<input id="ltext" type="button" value="Start LT Ext" />