Merge pull request #11882 from simonseyock/vector-source-load-events-doc
Improved documentation for feature load events.
This commit is contained in:
@@ -56,7 +56,7 @@ const styleCache = {
|
||||
};
|
||||
|
||||
const vectorSource = new VectorSource({
|
||||
loader: function (extent, resolution, projection) {
|
||||
loader: function (extent, resolution, projection, success, failure) {
|
||||
const url =
|
||||
serviceUrl +
|
||||
layer +
|
||||
@@ -83,6 +83,7 @@ const vectorSource = new VectorSource({
|
||||
alert(
|
||||
response.error.message + '\n' + response.error.details.join('\n')
|
||||
);
|
||||
failure();
|
||||
} else {
|
||||
// dataProjection will be read from document
|
||||
const features = esrijsonFormat.readFeatures(response, {
|
||||
@@ -91,8 +92,10 @@ const vectorSource = new VectorSource({
|
||||
if (features.length > 0) {
|
||||
vectorSource.addFeatures(features);
|
||||
}
|
||||
success(features);
|
||||
}
|
||||
},
|
||||
error: failure,
|
||||
});
|
||||
},
|
||||
strategy: tileStrategy(
|
||||
|
||||
@@ -74,7 +74,7 @@ const styles = {
|
||||
|
||||
const vectorSource = new VectorSource({
|
||||
format: new OSMXML(),
|
||||
loader: function (extent, resolution, projection) {
|
||||
loader: function (extent, resolution, projection, success, failure) {
|
||||
const epsg4326Extent = transformExtent(extent, projection, 'EPSG:4326');
|
||||
const client = new XMLHttpRequest();
|
||||
client.open('POST', 'https://overpass-api.de/api/interpreter');
|
||||
@@ -83,7 +83,9 @@ const vectorSource = new VectorSource({
|
||||
featureProjection: map.getView().getProjection(),
|
||||
});
|
||||
vectorSource.addFeatures(features);
|
||||
success(features);
|
||||
});
|
||||
client.addEventListener('error', failure);
|
||||
const query =
|
||||
'(node(' +
|
||||
epsg4326Extent[1] +
|
||||
|
||||
Reference in New Issue
Block a user