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: >
|
||||
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"
|
||||
resources:
|
||||
- https://code.jquery.com/jquery-1.11.2.min.js
|
||||
---
|
||||
<div id="map" class="map"></div>
|
||||
<form class="form-inline">
|
||||
|
||||
@@ -29,18 +29,20 @@ var vectorSource = new ol.source.Vector({
|
||||
',"spatialReference":{"wkid":102100}}') +
|
||||
'&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
|
||||
'&outSR=102100';
|
||||
|
||||
fetch(url).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(json) {
|
||||
// dataProjection will be read from document
|
||||
var features = esrijsonFormat.readFeatures(json, {
|
||||
featureProjection: projection
|
||||
});
|
||||
if (features.length > 0) {
|
||||
vectorSource.addFeatures(features);
|
||||
$.ajax({url: url, dataType: 'jsonp', success: function(response) {
|
||||
if (response.error) {
|
||||
alert(response.error.message + '\n' +
|
||||
response.error.details.join('\n'));
|
||||
} else {
|
||||
// dataProjection will be read from document
|
||||
var features = esrijsonFormat.readFeatures(response, {
|
||||
featureProjection: projection
|
||||
});
|
||||
if (features.length > 0) {
|
||||
vectorSource.addFeatures(features);
|
||||
}
|
||||
}
|
||||
});
|
||||
}});
|
||||
},
|
||||
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
|
||||
tileSize: 512
|
||||
@@ -95,12 +97,8 @@ selected.on('remove', function(evt) {
|
||||
featureProjection: map.getView().getProjection()
|
||||
}) + ']';
|
||||
var url = serviceUrl + layer + '/updateFeatures';
|
||||
var data = new FormData();
|
||||
data.append('f', 'json');
|
||||
data.append('features', payload);
|
||||
fetch(url, {method: 'POST', body: data}).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(result) {
|
||||
$.post(url, { f: 'json', features: payload }).done(function(data) {
|
||||
var result = JSON.parse(data);
|
||||
if (result.updateResults && result.updateResults.length > 0) {
|
||||
if (result.updateResults[0].success !== true) {
|
||||
var error = result.updateResults[0].error;
|
||||
@@ -119,12 +117,8 @@ draw.on('drawend', function(evt) {
|
||||
featureProjection: map.getView().getProjection()
|
||||
}) + ']';
|
||||
var url = serviceUrl + layer + '/addFeatures';
|
||||
var data = new FormData();
|
||||
data.append('f', 'json');
|
||||
data.append('features', payload);
|
||||
fetch(url, {method: 'POST', body: data}).then(function(response) {
|
||||
return response.json();
|
||||
}).then(function(result) {
|
||||
$.post(url, { f: 'json', features: payload }).done(function(data) {
|
||||
var result = JSON.parse(data);
|
||||
if (result.addResults && result.addResults.length > 0) {
|
||||
if (result.addResults[0].success === true) {
|
||||
feature.setId(result.addResults[0]['objectId']);
|
||||
|
||||
Reference in New Issue
Block a user