Javascript OpenLayers 3.13v:ol.format.GeoJSON()的问题
在OpenLayers 3.13v中,我获得了Javascript OpenLayers 3.13v:ol.format.GeoJSON()的问题,javascript,openlayers-3,Javascript,Openlayers 3,在OpenLayers 3.13v中,我获得了uncaughtAssertionError:AssertionFailed:当使用ol-debug.js设置url时必须设置格式,而uncaughtTypeError:无法使用ol.js读取未定义的的属性“V” 通过替换ol.source.GeoJSON 此外,如果我试图创建一个空层,比如 您必须将实例传递给源的格式选项: var vectorEuropa = new ol.layer.Vector({ id: 'europa', sour
uncaughtAssertionError:AssertionFailed:当使用ol-debug.js设置url时必须设置格式,而uncaughtTypeError:无法使用ol.js读取未定义的
的属性“V”
通过替换ol.source.GeoJSON
此外,如果我试图创建一个空层,比如
您必须将实例传递给源的格式
选项:
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
选项
如果要创建空源,则不应设置格式
:
var bbox = new ol.layer.Vector({
source: new ol.source.Vector()
});
要向上述源添加要素,您需要在视图投影中使用几何图形创建要素,例如使用bbox.getSource().addFeatures
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
});
var bbox = new ol.layer.Vector({
source: new ol.source.Vector()
});