Commit 236ad9ec by huyue

修复

1 parent 4855f8b5
...@@ -38,25 +38,32 @@ export default { ...@@ -38,25 +38,32 @@ export default {
}, },
created() { created() {
this.initMap(); this.initMap();
console.log('地图');
}, },
methods: { methods: {
async initMap() { async initMap() {
new GLMapSdk(async (mapapi) => { try {
new GLMapSdk(async (mapapi) => {
this.mapapi = mapapi; this.mapapi = mapapi;
console.log(mapapi, 'mapapi');
const map = await mapapi.invoke("Map", "mapContainer"); const map = await mapapi.invoke("Map", "mapContainer");
const { lng, lat } = this.info; const { lng, lat } = this.info;
mapapi.invoke("centerAndZoom", mapapi.invoke("Point", lng, lat), this.zoom); mapapi.invoke("centerAndZoom", mapapi.invoke("Point", lng, lat), this.zoom);
//向地图中添加缩放控件 //向地图中添加缩放控件
var ctrlNav = new window.BMap.NavigationControl({ // var ctrlNav = new window.BMap.NavigationControl({
anchor: BMAP_ANCHOR_TOP_LEFT, // anchor: BMAP_ANCHOR_TOP_LEFT,
type: BMAP_NAVIGATION_CONTROL_LARGE, // type: BMAP_NAVIGATION_CONTROL_LARGE,
}); // });
//地图缩放控件 //地图缩放控件
// map.addControl(ctrlNav); // map.addControl(ctrlNav);
mapapi.invoke('addControl', ctrlNav) // mapapi.invoke('addControl', ctrlNav)
mapapi.invoke('NavigationControl')
// mapapi.invoke('enableScrollWheelZoom') // mapapi.invoke('enableScrollWheelZoom')
this.drawMaker(mapapi, map); this.drawMaker(mapapi, map);
}); });
} catch (error) {
console.log(error);
}
}, },
// 激活位置 // 激活位置
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!