日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 前端技术 > vue >内容正文

vue

vue引入vue-amap

發(fā)布時間:2025/3/20 vue 36 豆豆
生活随笔 收集整理的這篇文章主要介紹了 vue引入vue-amap 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

高德全局引入vue

一、安裝

1、npm install vue-amap --save

2、在main.js中引入

import VueAMap from 'vue-amap' Vue.use(VueAMap) VueAMap.initAMapApiLoader({
key: '你的key',
plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor'],
// 默認高德 sdk 版本為 1.4.4
v: '1.4.4'
})

二、在組件中用

?

?

1、HTML

<el-amap
:plugin="plugin"
:center="center"
:zoom="zoom"
class="amap-demo">
<el-amap-marker v-for="marker in markers"
:position="marker.position"
:key="marker.id"
:events="marker.events"
:icon="'/static/police.png'">
</el-amap-marker>
<el-amap-info-window v-if="window"
:position="window.position"
:visible="window.visible"
:content="window.content"
:offset="window.offset">
</el-amap-info-window>
</el-amap>

2、script

data:

zoom: 12,
center: [113.883107, 22.590993], // 數(shù)據(jù)儲存 pointMarker:[], markers: [],
windows: [],
window: '',
plugin: [{
pName: 'ToolBar',
events: {
init (instance) {
// console.log(instance)
}
}
}] methods: point () {
let markers = []
let windows = []
let that = this
this.pointMarker.forEach((item, index) => {
markers.push({
position: [item.lng, item.lat],
icon: item.icon,
events: {
click () {
that.windows.forEach(window => {
window.visible = false
})
that.window = that.windows[index]
that.$nextTick(() => {
that.window.visible = true
})
}
}
})
windows.push({
position: [item.lng, item.lat],
content: '<div class="windows-text">' + '<div class="text-map">' +
'<p>' + '煙感報警-方形測試' + '</p>' +
'報警狀態(tài):' + item.status + '<br>' +
'報警時間:' + item.time + '<br>' +
'聯(lián)系人:' + item.linkman + '<br>' +
'聯(lián)系電話:' + item.phone + '<br>' +
'設備名稱:' + item.equipment + '<br>' +
'煙感環(huán)境溫度:' + item.temp + '<br>' +
'發(fā)現(xiàn)地址:' + item.site + '<br>' + '<div class="bottom">' +
'<button οnclick="getVideo()">' + '查看視頻' + '</button>' + '</div>' + '</div>' + '</div>',
offset: [5, -15],
visible: false
})
})
// 加窗體
this.markers = markers
// 加彈窗
this.windows = windows
}



注意要給高度顯示地圖 .amap-demo{
width: 100%;
height: 775px;
}

?

轉載于:https://www.cnblogs.com/luckyShuang/p/11527194.html

總結

以上是生活随笔為你收集整理的vue引入vue-amap的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內容還不錯,歡迎將生活随笔推薦給好友。