The following code intends to load geojson objects into a vector source, these objects are previously created as the output of a php routine:
var vectorSource = new ol.source.ServerVector({format: new ol.format.GeoJSON(),loader: function(extent, resolution, projection) { $.getJSON("postgis_geojson.php", function (data) { dataType:'jsonp' }).done(function ( data ) { var my_features = new ol.format.GeoJSON(); my_features =vectorSource.readFeatures(data); console.log (my_features); // first log, populated "my_features" object vectorSource.addFeatures(my_features); console.log(vectorSource); // second log, no data on the vectorSource });},strategy: ol.loadingstrategy.bbox,projection: 'EPSG:3857'}); The thing is that my_features object is populated so the problem seems to be the "add features" method...what am I missing ?, thanks in advance !
أكثر...
var vectorSource = new ol.source.ServerVector({format: new ol.format.GeoJSON(),loader: function(extent, resolution, projection) { $.getJSON("postgis_geojson.php", function (data) { dataType:'jsonp' }).done(function ( data ) { var my_features = new ol.format.GeoJSON(); my_features =vectorSource.readFeatures(data); console.log (my_features); // first log, populated "my_features" object vectorSource.addFeatures(my_features); console.log(vectorSource); // second log, no data on the vectorSource });},strategy: ol.loadingstrategy.bbox,projection: 'EPSG:3857'}); The thing is that my_features object is populated so the problem seems to be the "add features" method...what am I missing ?, thanks in advance !
أكثر...