Revert to jQuery for editing with Esri and IE 9
This commit is contained in:
@@ -5,6 +5,8 @@ shortdesc: Example of using an ArcGIS REST Feature Service in an editing applica
|
|||||||
docs: >
|
docs: >
|
||||||
This example loads features from ArcGIS REST Feature Service and allows to add new features or update existing features.
|
This example loads features from ArcGIS REST Feature Service and allows to add new features or update existing features.
|
||||||
tags: "vector, esri, ArcGIS, REST, Feature, Service, bbox, loading, server, edit, updateFeature, addFeature"
|
tags: "vector, esri, ArcGIS, REST, Feature, Service, bbox, loading, server, edit, updateFeature, addFeature"
|
||||||
|
resources:
|
||||||
|
- https://code.jquery.com/jquery-1.11.2.min.js
|
||||||
---
|
---
|
||||||
<div id="map" class="map"></div>
|
<div id="map" class="map"></div>
|
||||||
<form class="form-inline">
|
<form class="form-inline">
|
||||||
|
|||||||
@@ -29,18 +29,20 @@ var vectorSource = new ol.source.Vector({
|
|||||||
',"spatialReference":{"wkid":102100}}') +
|
',"spatialReference":{"wkid":102100}}') +
|
||||||
'&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
|
'&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
|
||||||
'&outSR=102100';
|
'&outSR=102100';
|
||||||
|
$.ajax({url: url, dataType: 'jsonp', success: function(response) {
|
||||||
fetch(url).then(function(response) {
|
if (response.error) {
|
||||||
return response.json();
|
alert(response.error.message + '\n' +
|
||||||
}).then(function(json) {
|
response.error.details.join('\n'));
|
||||||
// dataProjection will be read from document
|
} else {
|
||||||
var features = esrijsonFormat.readFeatures(json, {
|
// dataProjection will be read from document
|
||||||
featureProjection: projection
|
var features = esrijsonFormat.readFeatures(response, {
|
||||||
});
|
featureProjection: projection
|
||||||
if (features.length > 0) {
|
});
|
||||||
vectorSource.addFeatures(features);
|
if (features.length > 0) {
|
||||||
|
vectorSource.addFeatures(features);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
}});
|
||||||
},
|
},
|
||||||
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
|
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
|
||||||
tileSize: 512
|
tileSize: 512
|
||||||
@@ -95,12 +97,8 @@ selected.on('remove', function(evt) {
|
|||||||
featureProjection: map.getView().getProjection()
|
featureProjection: map.getView().getProjection()
|
||||||
}) + ']';
|
}) + ']';
|
||||||
var url = serviceUrl + layer + '/updateFeatures';
|
var url = serviceUrl + layer + '/updateFeatures';
|
||||||
var data = new FormData();
|
$.post(url, { f: 'json', features: payload }).done(function(data) {
|
||||||
data.append('f', 'json');
|
var result = JSON.parse(data);
|
||||||
data.append('features', payload);
|
|
||||||
fetch(url, {method: 'POST', body: data}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(result) {
|
|
||||||
if (result.updateResults && result.updateResults.length > 0) {
|
if (result.updateResults && result.updateResults.length > 0) {
|
||||||
if (result.updateResults[0].success !== true) {
|
if (result.updateResults[0].success !== true) {
|
||||||
var error = result.updateResults[0].error;
|
var error = result.updateResults[0].error;
|
||||||
@@ -119,12 +117,8 @@ draw.on('drawend', function(evt) {
|
|||||||
featureProjection: map.getView().getProjection()
|
featureProjection: map.getView().getProjection()
|
||||||
}) + ']';
|
}) + ']';
|
||||||
var url = serviceUrl + layer + '/addFeatures';
|
var url = serviceUrl + layer + '/addFeatures';
|
||||||
var data = new FormData();
|
$.post(url, { f: 'json', features: payload }).done(function(data) {
|
||||||
data.append('f', 'json');
|
var result = JSON.parse(data);
|
||||||
data.append('features', payload);
|
|
||||||
fetch(url, {method: 'POST', body: data}).then(function(response) {
|
|
||||||
return response.json();
|
|
||||||
}).then(function(result) {
|
|
||||||
if (result.addResults && result.addResults.length > 0) {
|
if (result.addResults && result.addResults.length > 0) {
|
||||||
if (result.addResults[0].success === true) {
|
if (result.addResults[0].success === true) {
|
||||||
feature.setId(result.addResults[0]['objectId']);
|
feature.setId(result.addResults[0]['objectId']);
|
||||||
|
|||||||
Reference in New Issue
Block a user