Vue中使用openlayers

安装openlayers

网址:npm-ol

安装:npm install ol



引用

参考网址:简单的地图



代码如下

注:我使用了一个新的页面

1、在components文件下,新建一个新的map.vue文件

代码如下:





2、显示,在配置路由router.js文件中引入:


import map from '@/components/map'



在const routes中添加如下代码 :



{

  path: '/',

  name: 'map',

  component: map

}


Vue中使用openlayers_第1张图片

效果如下图


Vue中使用openlayers_第2张图片

你可能感兴趣的:(Vue中使用openlayers)