OpenLayers 3.13v: issue with ol.format.GeoJSON()
OpenLayers 3.13v: issue with ol.format.GeoJSON()
在OpenLayers 3.13v中,我用ol-debug.js获得Uncaught AssertionError: Assertion failed: format must be set when url is set
,而用ol Uncaught TypeError: Cannot read property 'V' of undefined
.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
.
相关文章:
- 如何使用传单pip插件与纯GeoJSON数据
- 使用AJAX调用将GeoJSON数据拉入传单
- Mapbox JS,来自URL的GeoJSON featureCollection对象只添加了一个标记
- 使用D3.js和GeoJson在地图上的某些坐标上设置一个小图像
- 从传单数据到GeoJSON的多边形
- 用于在ng映射中加载GeoJSON的回调
- 使用.format在一些HTML代码中插入文本,会出现错误(Python)
- 使用D3.js和GeoJson在地图上显示States上的一些文本
- JS,使用geojson在googleapi中将标记显示为字符串
- 在传单上绘制GeoJSON
- Format for Excel VBA addWatermarkFromText
- 使用传单和geoJson监控对象
- 更新GeoJSON元素
- "responsed_to|format|“;引发UnknownFormat错误
- 基于唯一ID合并geojson
- Mapbox,无法在jquery回调中设置GeoJSON
- 如何将参数应用于String.prototype.format函数
- 如何避免传单javascript库中多个MultiPolygon GeoJSON层重叠
- d3.js,是否可以将超链接附加到GeoJSON文件
- OpenLayers 3.13v: issue with ol.format.GeoJSON()