vue传中文标点_vue项目引入第三方高德地图实现标点定位
vue項(xiàng)目中,高德地圖使用。
引入vue中。異步導(dǎo)入vue中。
gaoDe(key) {
window.onApiLoaded = function () {
var map = new AMap.Map('container', {
resizeEnable: true,
center: [113.951955, 22.530825],
zoom: 16
});
}
var url = `https://webapi.amap.com/maps? v=1.4.15&key=${key}&callback=onApiLoaded`;
var jsapi = document.createElement('script');
jsapi.charset = 'utf-8';
jsapi.src = url;
document.head.appendChild(jsapi);
mounted() {
this.gaoDe('key');
},
在vue組件中使用,直接寫在mouted中會出現(xiàn)AMap未定義的報錯!
目前,個人是使用定時器解決的。
// 地圖接口API
mapCom() {
let _this = this;
window.onLoad = function () {
var map = new AMap.Map('mapBox', {
resizeEnable: true,
center: [113.951955, 22.530825],
zoom: 16
});
// console.log( _this.mapArray);
// 渲染坐標(biāo)
// console.log(_this.status==false)
setTimeout(() => {
if (_this.status == false) {
return;
}
// console.log(_this.mapArray);
_this.mapArray.forEach(item => {
// console.log(item)
var marker = new AMap.Marker({
map: map,
icon: "//a.amap.com/jsapi_demos/static/demo-center/icons/poi-marker-default.png",
position: item,
offset: new AMap.Pixel(-10, -30)
});
})
}, 1000)
// console.log(_this.mapArray);
map.plugin(["AMap.ToolBar"], function () {
map.addControl(new AMap.ToolBar());
});
}
var url = `https://webapi.amap.com/maps?v=1.4.15&key=91d89e79a544b9ab37aa0147aec9bd0a&callback=onLoad`;
var jsapi = document.createElement('script');
jsapi.charset = 'utf-8';
jsapi.src = url;
document.head.appendChild(jsapi);
},
總結(jié)
以上是生活随笔為你收集整理的vue传中文标点_vue项目引入第三方高德地图实现标点定位的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: c# 标准正太分布函数_数据标准化处理中
- 下一篇: CentOS配置国内(阿里云)镜像加速器