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)
鑽研不易,轉載請注明出處。。。。。。