vue项目中openlayers绘制行政区划


Posted in Vue.js onDecember 24, 2020

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.js 相关文章推荐
Vue实现点击当前行变色
Dec 14 Vue.js
Vue解决移动端弹窗滚动穿透问题
Dec 15 Vue.js
vue 使用 sortable 实现 el-table 拖拽排序功能
Dec 26 Vue.js
vue-resource 拦截器interceptors使用详解
Jan 18 Vue.js
解决vue项目本地启动时无法携带cookie的问题
Feb 06 Vue.js
vue-router路由懒加载及实现的3种方式
Feb 28 Vue.js
关于Vue Router的10条高级技巧总结
May 06 Vue.js
SSM VUE Axios详解
Oct 05 Vue.js
Vue的过滤器你真了解吗
Feb 24 Vue.js
vue+iview实现手机号分段输入框
Mar 25 Vue.js
VUE之图片Base64编码使用ElementUI组件上传
Apr 09 Vue.js
分享一个vue实现的记事本功能案例
Apr 11 Vue.js
Vue+penlayers实现多边形绘制及展示
Dec 24 #Vue.js
Vue使用鼠标在Canvas上绘制矩形
Dec 24 #Vue.js
vue绑定class的三种方法
Dec 24 #Vue.js
全面解析Vue中的$nextTick
Dec 24 #Vue.js
vue实现登录、注册、退出、跳转等功能
Dec 23 #Vue.js
vue下拉刷新组件的开发及slot的使用详解
Dec 23 #Vue.js
Vue3 实现双盒子定位Overlay的示例
Dec 22 #Vue.js
You might like
PHP5与MySQL数据库操作常用代码 收集
2010/03/21 PHP
PHP利用MySQL保存session的实现思路及示例代码
2014/09/09 PHP
Laravel5.4框架中视图共享数据的方法详解
2019/09/05 PHP
tp5 实现列表数据根据状态排序
2019/10/18 PHP
基于jQuery UI CSS Framework开发Widget的经验
2010/08/21 Javascript
jquery监听div内容的变化具体实现思路
2013/11/04 Javascript
jQuery插件jQuery-JSONP开发ajax调用使用注意事项
2013/11/22 Javascript
jQuery.form插件的使用及跨域异步上传文件
2016/04/27 Javascript
jQuery插件FusionCharts绘制的3D双柱状图效果示例【附demo源码】
2017/04/20 jQuery
浅谈Vue2.0父子组件间事件派发机制
2018/01/08 Javascript
JavaScript中Object基础内部方法图
2018/02/05 Javascript
layui实现数据表格自定义数据项
2019/10/26 Javascript
JavaScript计算正方形面积
2019/11/26 Javascript
50行代码实现贪吃蛇(具体思路及代码)
2013/04/27 Python
python操作ie登陆土豆网的方法
2015/05/09 Python
python实现实时监控文件的方法
2016/08/26 Python
Python编写Windows Service服务程序
2018/01/04 Python
python kmeans聚类简单介绍和实现代码
2018/02/23 Python
python的pandas工具包,保存.csv文件时不要表头的实例
2018/06/14 Python
Python中创建二维数组
2018/10/17 Python
利用Python半自动化生成Nessus报告的方法
2019/03/19 Python
在Django下创建项目以及设置settings.py教程
2019/12/03 Python
Python pandas对excel的操作实现示例
2020/07/21 Python
创造美妙香氛体验:Aera扩散器和香水
2018/11/25 全球购物
HomeAway澳大利亚:预订你的度假屋,公寓、度假村、别墅等
2019/02/20 全球购物
写好求职信第一句话的技巧
2013/10/26 职场文书
新闻专业应届生求职信
2013/10/31 职场文书
董事长岗位职责
2013/11/30 职场文书
财务主管岗位职责
2014/02/28 职场文书
司机职责范本
2014/03/08 职场文书
2014年公务员工作总结
2014/11/18 职场文书
2014年纠风工作总结
2014/12/08 职场文书
教师听课评语大全
2014/12/31 职场文书
党支部书记岗位职责
2015/02/15 职场文书
个性与发展自我评价
2015/03/06 职场文书
2016高考冲刺决心书
2015/09/23 职场文书