我有这个GeoJSON文件(polygon.geojson)...
{
"type": "Feature",
"geometry": { "type": "Polygon", "coordinates": [ [ [73, 15], [83.0, 15], [83, 5], [73, 5], [73, 15] ] ] },
"properties": { "name": "Foo" }
}
Run Code Online (Sandbox Code Playgroud)
...并将其用作矢量源:
var vectorSource = new ol.source.Vector({
url: 'polygon.geojson',
format: new ol.format.GeoJSON(),
projection : 'EPSG:4326',
});
Run Code Online (Sandbox Code Playgroud)
现在我希望得到以下内容:
var extent = vectorSource.getExtent();
Run Code Online (Sandbox Code Playgroud)
extent但是,它的价值是:
Array [ Infinity, Infinity, -Infinity, -Infinity ]
Run Code Online (Sandbox Code Playgroud)
我正在使用OL 3.9.0,并且正确显示了带有此源的矢量图层.我究竟做错了什么?