Better error handling in the ArcGIS REST vector examples

This commit is contained in:
Bart van den Eijnden
2015-04-22 11:57:33 +02:00
parent 2a95049ac4
commit 3b8e272a11
2 changed files with 22 additions and 12 deletions

View File

@@ -31,12 +31,17 @@ var vectorSource = new ol.source.Vector({
'&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' + '&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
'&outSR=102100'; '&outSR=102100';
$.ajax({url: url, dataType: 'jsonp', success: function(response) { $.ajax({url: url, dataType: 'jsonp', success: function(response) {
// dataProjection will be read from document if (response.error) {
var features = esrijsonFormat.readFeatures(response, { alert(response.error.message + '\n' +
featureProjection: projection response.error.details.join('\n'));
}); } else {
if (features.length > 0) { // dataProjection will be read from document
vectorSource.addFeatures(features); var features = esrijsonFormat.readFeatures(response, {
featureProjection: projection
});
if (features.length > 0) {
vectorSource.addFeatures(features);
}
} }
}}); }});
}, },

View File

@@ -77,12 +77,17 @@ var vectorSource = new ol.source.Vector({
'&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' + '&geometryType=esriGeometryEnvelope&inSR=102100&outFields=*' +
'&outSR=102100'; '&outSR=102100';
$.ajax({url: url, dataType: 'jsonp', success: function(response) { $.ajax({url: url, dataType: 'jsonp', success: function(response) {
// dataProjection will be read from document if (response.error) {
var features = esrijsonFormat.readFeatures(response, { alert(response.error.message + '\n' +
featureProjection: projection response.error.details.join('\n'));
}); } else {
if (features.length > 0) { // dataProjection will be read from document
vectorSource.addFeatures(features); var features = esrijsonFormat.readFeatures(response, {
featureProjection: projection
});
if (features.length > 0) {
vectorSource.addFeatures(features);
}
} }
}}); }});
}, },