Commit b3c70ee1 by 胡悦

更新地图sdk

1 parent da8d9593
...@@ -24,38 +24,6 @@ export default { ...@@ -24,38 +24,6 @@ export default {
type: Object, type: Object,
default: function () { default: function () {
return { return {
// activeDate: "2022-02-22 17:57:23",
// address: "广东省深圳市南山区科技园",
// bsAddress: "广东省深圳市南山区科技园",
// bsLat: "22.551794",
// bsLng: "113.941085",
// bsTime: null,
// deviceType: null,
// deviceTypeStr: null,
// elat: "22.550615",
// elng: "113.938668",
// finalBsTime: null,
// finalGpsTime: null,
// gpsLat: "22.550615",
// gpsLng: "113.938668",
// lastBsAddress: "",
// lastGpsAddress: "广东省深圳市南山区科技园",
// lastPoiAddress: "广东省深圳市南山区科技园",
// lastPoiTime: "2018-10-15 16:14:11",
// lat: "22.550615",
// lng: "113.938668",
// name: "仲利测试1",
// ownerName: "仲利测试1",
// poiType: "GPS",
// shopName: "仲利国际租赁有限公司",
// sn: "7140626339",
// source: null,
// sourceStr: null,
// standNo: "LGBF5AE08FR305952",
// time: '2022-02-22 17:57:23',
// type: 2,
// vin: "LGBF5AE08FR305952",
// workOrderNo: "481985751282679808",
}; };
}, },
}, },
...@@ -73,7 +41,7 @@ export default { ...@@ -73,7 +41,7 @@ export default {
}, },
methods: { methods: {
async initMap() { async initMap() {
new GLMapSdk(1, async (mapapi) => { new GLMapSdk({env: 1}, async (mapapi) => {
this.mapapi = mapapi; this.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;
...@@ -84,7 +52,8 @@ export default { ...@@ -84,7 +52,8 @@ export default {
type: BMAP_NAVIGATION_CONTROL_LARGE, type: BMAP_NAVIGATION_CONTROL_LARGE,
}); });
//地图缩放控件 //地图缩放控件
map.addControl(ctrlNav); // map.addControl(ctrlNav);
mapapi.invoke('addControl', ctrlNav)
// mapapi.invoke('enableScrollWheelZoom') // mapapi.invoke('enableScrollWheelZoom')
this.drawMaker(mapapi, map); this.drawMaker(mapapi, map);
}); });
...@@ -171,7 +140,8 @@ export default { ...@@ -171,7 +140,8 @@ export default {
infoDiv.querySelector("#locateTypeGps").classList.add("active"); infoDiv.querySelector("#locateTypeGps").classList.add("active");
infoDiv.querySelector("#locateTypeBase").classList.remove("active"); infoDiv.querySelector("#locateTypeBase").classList.remove("active");
marker.setPosition(self.mapapi.invoke("Point", info.lng, info.lat)); marker.setPosition(self.mapapi.invoke("Point", info.lng, info.lat));
map.openInfoWindow(marker.infoWindow, marker.getPosition()); // map.openInfoWindow(marker.infoWindow, marker.getPosition());
self.mapapi.invoke("mapOpenInfoWindow", marker.infoWindow, self.mapapi.invoke('markerGetPosition'));
} }
// 基站位置信息 // 基站位置信息
...@@ -182,7 +152,8 @@ export default { ...@@ -182,7 +152,8 @@ export default {
infoDiv.querySelector("#locateTypeBase").classList.add("active"); infoDiv.querySelector("#locateTypeBase").classList.add("active");
console.log(self.mapapi.invoke("Point", info.bsLng, info.bsLat), "基站点位置", map); console.log(self.mapapi.invoke("Point", info.bsLng, info.bsLat), "基站点位置", map);
marker.setPosition(self.mapapi.invoke("Point", info.bsLng, info.bsLat)); marker.setPosition(self.mapapi.invoke("Point", info.bsLng, info.bsLat));
map.openInfoWindow(marker.infoWindow, marker.getPosition()); // map.openInfoWindow(marker.infoWindow, marker.getPosition());
self.mapapi.invoke("mapOpenInfoWindow", marker.infoWindow, self.mapapi.invoke('markerGetPosition'));
} }
infoDiv.querySelector("#locateTypeGps").onclick = function (e) { infoDiv.querySelector("#locateTypeGps").onclick = function (e) {
...@@ -208,14 +179,19 @@ export default { ...@@ -208,14 +179,19 @@ export default {
width: 380, // 信息窗口宽度 width: 380, // 信息窗口宽度
height: 170, // 信息窗口高度 height: 170, // 信息窗口高度
}; };
let infoWindow = this.mapapi.invoke("InfoWindow", div, opts); const {mapapi} = this;
let infoWindow = mapapi.invoke("InfoWindow", div, opts);
marker.infoWindow = infoWindow; marker.infoWindow = infoWindow;
map.openInfoWindow(infoWindow, marker.getPosition()); // map.openInfoWindow(infoWindow, marker.getPosition());
mapapi.invoke("mapOpenInfoWindow", infoWindow, mapapi.invoke('markerGetPosition'));
//给Marker绑定单击事件 //给Marker绑定单击事件
marker.addEventListener("click", markerClick); // marker.addEventListener("click", markerClick);
mapapi.invoke("markerAddEventListener", 'click', markerClick)
function markerClick(e) { function markerClick(e) {
map.openInfoWindow(infoWindow, marker.getPosition()); // map.openInfoWindow(infoWindow, marker.getPosition());
mapapi.invoke("mapOpenInfoWindow", infoWindow, mapapi.invoke('markerGetPosition'));
} }
return infoWindow; return infoWindow;
}, },
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!