leaflet-component-map
Version:
### 快速开始
84 lines (68 loc) • 1.73 kB
Markdown
```bash
npm install leaflet-component-map -S
```
```javascript
//全部引入
import 'leaflet-component-map/dist/css/index.css'
import rgMap from 'leaflet-component-map'
Vue.use(rgMap)
//按需引入
import 'leaflet-component-map/dist/css/mapBasic.css'
import mapBasic from 'leaflet-component-map'
Vue.use(mapBasic)
import 'leaflet-component-map/dist/css/mapTool.css'
import { mapTool } from 'leaflet-component-map'
Vue.use(mapTool)
```
```html
// 组件内使用
<rg-map-basic :configObj="configObj" ref="basicMap" @mapReady="mapReady">
<rg-map-tool
:tools="tools"
@pointDbclick="pointDbclick"
@pointClick="pointClick"
></rg-map-tool>
</rg-map-basic>
```
```javascript
mounted() {
this.initConfigObj()
},
methods: {
initConfigObj() {
this.configObj = {
osmUrl: "http://10.10.167.122:8089/map/yantai/{z}/{x}/{y}.png",
southWest: [37.590442, 121.057361], // 西南角坐标
northEast: [37.631471, 121.194953], // 东北角左边
min: 16,
max: 19,
mapCenter: [37.60966, 121.128402],
}
},
mapReady(e) {
this.map = e
}
}
```
mapReady 方法接收地图初始化完成后的 map,在外部使用。
```javascript
methods: {
mapReady(e) {
this.map = e
}
}
```
```javascript
data(){
return{
tools: ["distance", "area", "markPoint", "markLine", "markArea", "clear"],
}
}
```