![](/img/trans.png)
[英]OpenLayers: how can be ol.FeatureOverlay replaced in 3.13v?
[英]OpenLayers 3.13v: issue with ol.format.GeoJSON()
在 OpenLayers 3.13v 中,我获得了Uncaught AssertionError: Assertion failed: format must be set when url is set
with ol-debug.js,而Uncaught TypeError: Cannot read property 'V' of undefined
with ol.js
我通过替换本例中的ol.source.GeoJSON
来使用以下代码
var vectorEuropa = new ol.layer.Vector({
id: 'europa',
source: new ol.source.Vector({
format: ol.format.GeoJSON(),
projection: 'EPSG:3857',
url: '../assets/data/nutsv9_lea.geojson'
}),
style: defaultEuropa
});
此外,如果我尝试像本例中那样创建一个空层,我也会遇到同样的问题
var bbox = new ol.layer.Vector({
source: new ol.source.Vector({
format: ol.format.GeoJSON()
})
});
您必须将实例传递给源的format
选项:
var vectorEuropa = new ol.layer.Vector({
id: 'europa',
source: new ol.source.Vector({
format: new ol.format.GeoJSON(),
url: '../assets/data/nutsv9_lea.geojson'
}),
style: defaultEuropa
});
另请注意, ol.source.Vector
没有projection
选项。
如果要创建空源,则不应设置format
:
var bbox = new ol.layer.Vector({
source: new ol.source.Vector()
});
要向上面的源添加功能,您需要在视图投影中使用几何图形创建它们,例如使用bbox.getSource().addFeatures
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.