ol3之加載geojson數據


ol3之加載geojson數據

數據:

let data  = {
  "type": "Feature",
  "geometry": {
    "type": "Point",
    "coordinates": [125.6, 10.1]
  },
  "properties": {
    "name": "Dinagat Islands"
  }
}

加載圖層:

var vectorSource = new ol.source.Vector({
        features: (new ol.format.GeoJSON()).readFeatures(data)
      });
var vectorLayer = new ol.layer.Vector({
        source: vectorSource,
        style: ''
      });
this.map.addLayer(vectorLayer)

定位:

let extent = vectorSource.getExtent()
this.view.fit(extent)

 

 

 

鑽研不易,轉載請注明出處。。。。。。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM