openlayers3 undefined is not a constructor error on ol.source.StaticVector

南楼画角 提交于 2021-02-08 11:22:20

问题


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'
	})
});

errors out with:

TypeError: undefined is not a constructor (evaluating 'new ol.source.StaticVector({
            format: new ol.format.GeoJSON(),
            projection: 'EPSG:3857'
        })')
    global code

I realize, there was an API change, since the book came out, but I can't find what StaticVector was replaced with.


回答1:


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.

See this release details

https://github.com/openlayers/openlayers/releases/tag/v3.5.0



来源:https://stackoverflow.com/questions/42151692/openlayers3-undefined-is-not-a-constructor-error-on-ol-source-staticvector

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!