Modify OSM and WFS examples to use FeatureUrlFunction instead of FeatureLoader
This commit is contained in:
@@ -87,19 +87,13 @@ var styles = {
|
||||
}
|
||||
};
|
||||
|
||||
var osmxmlFormat = new ol.format.OSMXML();
|
||||
|
||||
var vectorSource = new ol.source.Vector({
|
||||
loader: function(extent, resolution, projection) {
|
||||
format: new ol.format.OSMXML(),
|
||||
url: function(extent, resolution, projection) {
|
||||
var epsg4326Extent =
|
||||
ol.proj.transformExtent(extent, projection, 'EPSG:4326');
|
||||
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
|
||||
return 'http://overpass-api.de/api/xapi?map?bbox=' +
|
||||
epsg4326Extent.join(',');
|
||||
$.ajax(url).then(function(response) {
|
||||
var features = osmxmlFormat.readFeatures(response,
|
||||
{featureProjection: projection});
|
||||
vectorSource.addFeatures(features);
|
||||
});
|
||||
},
|
||||
strategy: ol.loadingstrategy.tile(ol.tilegrid.createXYZ({
|
||||
maxZoom: 19
|
||||
|
||||
Reference in New Issue
Block a user