openlayers3 undefined不是ol.source.StaticVector上的构造函数错误 [英] openlayers3 undefined is not a constructor error on ol.source.StaticVector
问题描述
我正在使用ol v3.20.1学习openlayers3
在本书中,我已经讲到了要点,在这里我可以使用StaticVector读取/写入GeoJSON,但可以使用以下代码:
I am learning openlayers3 with ol v3.20.1
I've got to the point in the book, where I can read/write GeoJSON with StaticVector, but the following code:
var statVec = new ol.layer.Vector({
source: new ol.source.StaticVector({
format: new ol.format.GeoJSON(),
projection: 'EPSG:3857'
})
});
出现错误:
TypeError: undefined is not a constructor (evaluating 'new ol.source.StaticVector({
format: new ol.format.GeoJSON(),
projection: 'EPSG:3857'
})')
global code
我知道,自从这本书问世以来,API有了变化,但是我找不到用哪个StaticVector代替.
I realize, there was an API change, since the book came out, but I can't find what StaticVector was replaced with.
推荐答案
ol.source.StaticVector
以及其他类似的实验Vector源.关于您的问题,将 ol.source.StaticVector
替换为 ol.source.Vector
.
ol.source.StaticVector
along with other similar experimental Vector sources were removed in v3.5.0. Regarding your question ol.source.StaticVector
is replaced with ol.source.Vector
.
查看此版本的详细信息
https://github.com/openlayers/openlayers/releases/tag/v3.5.0
这篇关于openlayers3 undefined不是ol.source.StaticVector上的构造函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!