美文网首页
vue中openlayers的简单使用

vue中openlayers的简单使用

作者: xsmile21 | 来源:发表于2022-06-29 10:16 被阅读0次

1、安装ol

npm install ol

2、dom部分

<div id="map"></div>

3、初始化地图(这里以深圳举例)

data() {
   return {
     map: null
   };
}
this.map = new Map({
    target: "map",
    layers: [
       new TileLayer({
         source: new OSM()
       })
    ],
    view: new View({
    projection: "EPSG:4326",  // 使用这个坐标系
    center: [114.064839, 22.548857],  // 深圳
    zoom: 12
   })
});

4、需要引入的东西

import "ol/ol.css";
import { Map, View } from "ol";
import TileLayer from "ol/layer/Tile";
import OSM from "ol/source/OSM";

页面如下所示:


相关文章

网友评论

      本文标题:vue中openlayers的简单使用

      本文链接:https://www.haomeiwen.com/subject/zcetbrtx.html