首先在vue中使用,需要安装相关依赖
npm install leaflet
基于前面使用leaflet绘制平面图(一)的代码,修改得一下内容,相对与html会出现一些问题例如:标记图标未显示,需要声明icon
import * as L from 'leaflet'
import icon from 'leaflet/dist/images/marker-icon.png'
import iconShadow from 'leaflet/dist/images/marker-shadow.png'
完整代码如下
<template>
<div id="imageMap" />
</template>
<script>
import 'leaflet/dist/leaflet.css'
import 'leaflet/dist/leaflet'
import 'leaflet/dist/leaflet-src'
import 'leaflet/dist/leaflet-src.esm'
import * as L from 'leaflet'
import icon from 'leaflet/dist/images/marker-icon.png'
import iconShadow from 'leaflet/dist/images/marker-shadow.png'
const DefaultIcon = L.icon({
iconUrl: icon,
shadowUrl: iconShadow
})
L.Marker
因篇幅问题不能全部显示,请点此查看更多更全内容