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)
钻研不易,转载请注明出处。。。。。。
原文:https://www.cnblogs.com/s313139232/p/15253749.html