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";
页面如下所示:
网友评论