Loading Source Vector (features Won't Show?)
I have a function that loads a vector source from a local geojson file. Problem is, I need it to be remote for one of the layers, yet the features never show despite loading the s
Solution 1:
So all I was missing was adding {featureProjection: 'EPSG:3857'} to readFeatures so that the features would be projected in the map view correctly... (since that is the map projection)
Fixed it by replacing
var features = new ol.format.GeoJSON().readFeatures(json.data);
With
var features = format.readFeatures(json.data, {featureProjection: 'EPSG:3857'});
Found it through https://stackoverflow.com/a/32455939/2340999 and the features are showing in the proper positions now!
Thank you for all the suggestions!
Solution 2:
Change this
var features = new ol.format.GeoJSON().readFeatures(json.data);
to this
var features = (new ol.format.GeoJSON()).readFeatures(json.data);
Solution 3:
I have done this using the example available here: http://openlayersbook.github.io/ch11-creating-web-map-apps/example-03.html
Not sure if that helps.
Post a Comment for "Loading Source Vector (features Won't Show?)"