下载ol
npm i ol -S
<!--test-->
<template>
<div style="height: 100vh;width: 100vw;" id="map"></div>
</template>
<script setup>
import 'ol/ol.css'
import { Map, View } from 'ol'
import TileLayer from 'ol/layer/Tile'
import OSM from 'ol/source/OSM'
onMounted(() => {
new Map({
target: "map",
layers: [
new TileLayer({
source: new OSM()
})
],
view: new View({
projection: "EPSG:4326", //使用这个坐标系
center: [104.704968, 31.540962], //西南科技大学
zoom: 15
})
});
})
</script>