Clarification and use callbacks in examples

This commit is contained in:
Simon Seyock
2021-01-05 09:40:20 +01:00
parent 90c25012b9
commit 125d0d62a8
4 changed files with 10 additions and 5 deletions

View File

@@ -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] +