Replace extentUrlFunction with generic loadingFunction

This commit is contained in:
Tom Payne
2014-03-13 20:39:58 +01:00
parent b8869805a7
commit 9e75684823
3 changed files with 16 additions and 15 deletions

View File

@@ -87,14 +87,17 @@ var styles = {
}
};
var epsg3857ToEPSG4326 = ol.proj.getTransform('EPSG:3857', 'EPSG:4326');
var vectorSource = new ol.source.ServerVector({
extentUrlFunction: function(extent, resolution) {
var epsg4326Extent = epsg3857ToEPSG4326(extent, []);
return 'http://overpass-api.de/api/xapi?map?bbox=' +
epsg4326Extent.join(',');
},
format: new ol.format.OSMXML(),
loadingFunction: function(extent, resolution, projection) {
var transform = ol.proj.getTransform(projection, 'EPSG:4326');
var epsg4326Extent = transform(extent, []);
var url = 'http://overpass-api.de/api/xapi?map?bbox=' +
epsg4326Extent.join(',');
$.ajax(url).then(function(response) {
vectorSource.readFeatures(response);
});
},
loadingStrategy: ol.loadingstrategy.createTile(new ol.tilegrid.XYZ({
maxZoom: 19
})),