2017-02-10 60 views
0

我正在學習openlayers3與ol v3.20.1
我已經到了書中的地步,我可以用StaticVector讀/寫GeoJSON,但是下面的代碼:openlayers3 undefined不是ol.source.StaticVector上的構造函數錯誤

var statVec = new ol.layer.Vector({ 
 
\t source: new ol.source.StaticVector({ 
 
\t \t format: new ol.format.GeoJSON(), 
 
\t \t projection: 'EPSG:3857' 
 
\t }) 
 
});

錯誤出具有:

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

我意識到,自從本書出來以後,API發生了一些變化,但我找不到什麼StaticVector被替換了。

回答

2

ol.source.StaticVector以及其他類似的實驗性載體源在v3.5.0中被去除。關於您的問題ol.source.StaticVector被替換爲ol.source.Vector

參閱本新聞稿詳情

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

+0

是的,謝謝。它有幫助,但'StaticVector'在資源中沒有提及,你已經與鏈接共享。 – igoryonya

+0

是的沒有提到,但我不知道爲什麼? 'ol.source.ServerVector'類似於此版本中提及並刪除的內容 –

相關問題