I am struggling with building OL3 Vector layer BBOX strategy loading. So far I can easily load Geojson file with valid json syntax, however this is one time strategy. My ano
To get this working with the newest version of OL3 (v3.7.0) I had to read the features using the GeoJSON format class.
var geoJSONFormat = new ol.format.GeoJSON();
var vectorSource = new ol.source.Vector({
loader: function(extent, resolution, projection) {
var url = 'geojson2.php?p=' + extent.join(',');
$.ajax({
url: url,
success: function(data) {
var features = geoJSONFormat.readFeatures(data);
vectorSource.addFeatures(features);
}
});
},
strategy: ol.loadingstrategy.bbox
});