I have this GeoJSON file (polygon.geojson)...
{
"type": "Feature",
"geometry": { "type": "Polygon", "coordinates": [ [ [73, 15], [83.0, 15], [83, 5], [73, 5], [73, 15] ] ] },
"properties": { "name": "Foo" }
}
...and use it as vector source:
var vectorSource = new ol.source.Vector({
url: 'polygon.geojson',
format: new ol.format.GeoJSON(),
projection : 'EPSG:4326',
});
Now I want to get the extent with:
var extent = vectorSource.getExtent();
The value of extent
, however, is:
Array [ Infinity, Infinity, -Infinity, -Infinity ]
I'm using OL 3.9.0 and the vector layer with this source is displayed properly. What am I doing wrong?
ol.js
byol-debug.js
and step into the getExtent method to really see what's going on (using your browser Dev Tool). Maybe that could help. – ThralldomuseSpatialIndex
or call the method before the vector source has loaded any features? – Chalaza