久久r热视频,国产午夜精品一区二区三区视频,亚洲精品自拍偷拍,欧美日韩精品二区

您的位置:首頁技術文章
文章詳情頁

vue項目中openlayers繪制行政區劃

瀏覽:2日期:2022-10-16 14:46:06

vue項目中openlayers畫行政區劃(區域范圍),供大家參考,具體內容如下

原理

在地圖上畫需要的范圍,實際上就是在地圖上打上一圈點,然后依次將這些點用線連接,就形成了范圍

引用相應的ol模塊

import VectorLayer from ’ol/layer/Vector’import VectorSource from ’ol/source/Vector’import { Map, View, Feature } from ’ol’import { Style, Icon, Stroke } from ’ol/style’import { Point, LineString, Polygon } from ’ol/geom’

獲取范圍點

這里我將點放在json文件中,然后通過axios讀取json文件截圖:

vue項目中openlayers繪制行政區劃

axios.get(’static/常德市.json’).then((res) => { let arr = res.data.coordinates let polygonFeature = new Feature({ type: ’polygon’, geometry: new Polygon(arr[0]) }) polygonFeature.setStyle(new Style({ stroke: new Stroke({ width: 2, color: [255, 255, 0, 0.8] }), fill: new Fill({ color: [248, 172, 166, 0.2] }) // text: new Text({ // text: ’這是區域’ // }) })) let polygonLayer = new VectorLayer({ source: new VectorSource({ features: [polygonFeature] }) }) this.gmap.addLayer(polygonLayer) }) axios.get(’static/懷化市沅陵縣.json’).then((res) => { let arr = res.data.coordinates let polygonFeature = new Feature({ type: ’polygon’, geometry: new Polygon(arr[0]) }) polygonFeature.setStyle(new Style({ stroke: new Stroke({ width: 2, color: [255, 255, 0, 0.8] }), fill: new Fill({ color: [248, 172, 166, 0.2] }) // text: new Text({ // text: ’這是區域’ // }) })) let polygonLayer = new VectorLayer({ source: new VectorSource({ features: [polygonFeature] }) }) this.gmap.addLayer(polygonLayer) })

vue項目中openlayers繪制行政區劃

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持好吧啦網。

標簽: Vue
相關文章:
主站蜘蛛池模板: 泽库县| 漳浦县| 龙川县| 称多县| 江阴市| 辽中县| 昔阳县| 建德市| 连城县| 子洲县| 和田市| 永城市| 固阳县| 汨罗市| 巴林左旗| 汽车| 德化县| 东光县| 腾冲县| 乐亭县| 汝城县| 西安市| 巨鹿县| 嫩江县| 沈丘县| 湖南省| 甘谷县| 前郭尔| 托克托县| 阜平县| 新营市| 金秀| 两当县| 凤庆县| 上蔡县| 闵行区| 潞西市| 乐业县| 仙居县| 平凉市| 叙永县|