Better error handling in the ArcGIS REST vector examples
This commit is contained in:
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}});
|
}});
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user