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