diff --git a/examples/vector-esri-edit.html b/examples/vector-esri-edit.html index 2600f955a7..ff4ecd84c0 100644 --- a/examples/vector-esri-edit.html +++ b/examples/vector-esri-edit.html @@ -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 ---
diff --git a/examples/vector-esri-edit.js b/examples/vector-esri-edit.js index 7d268d3afb..d646f18b26 100644 --- a/examples/vector-esri-edit.js +++ b/examples/vector-esri-edit.js @@ -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']);