Commit 93d36208 by chenwq

getLocation,地图版本切换

1 parent 0b816dcd
......@@ -46,7 +46,7 @@ export default {
// new GLMap(mapapi => {
window.mapapi = mapapi;
init(id);
resolve()
resolve(GLMap)
})
} else {
checkLoadedTimeoutId = check();
......
......@@ -3,7 +3,7 @@ const MAPGEO = {
getGeocoder: function () {
// let AMap = window.AMap;
return new Promise((resolve) => {
MAPGEO.geocoder = window.mapapi.invoke('Geocoder')
MAPGEO.geocoder = window.mapapiversion1 ? window.mapapiversion1.invoke('Geocoder') : window.mapapi.invoke('Geocoder')
resolve(MAPGEO.geocoder)
// AMap.service("AMap.Geocoder", function () {
// //回调函数
......@@ -53,9 +53,10 @@ const MAPGEO = {
}
function geocoderGetAdr(arr, initIdx) {
const mapapi = window.mapapiversion1 ? window.mapapiversion1 : window.mapapi
const timeoutId = window.setTimeout(() => {
arr.forEach((item, idx) => {
window.mapapi.invoke('getLocation', window.mapapi.invoke('Point', item[0], item[1]), res => {
mapapi.invoke('getLocation', mapapi.invoke('Point', Number(item[0]), Number(item[1])), res => {
const {content: {poi_desc, address_detail: {province, city, district, town, street}}} = res
data[initIdx + idx].transferAddress = province + city + district + town + street + poi_desc;
obj.totalNum++;
......
......@@ -325,7 +325,11 @@ export default defineComponent({
// }
// });
onMounted(() => {
mapContentRefs.value.initMap("container");
mapContentRefs.value.initMap("container").then(GLMap => {
new GLMap({ version: 1 }, mapapi => {
window.mapapiversion1 = mapapi;
})
});
// mapContentRefs.value.initMap("container").then(res => {
// mapContentRefs.value.getLocation();
// })
......@@ -407,12 +411,7 @@ export default defineComponent({
locates.push(item.wifiLocation);
item.wifiLocation.transferAddress = "";
}
window.mapapi.invoke('getLocation', window.mapapi.invoke('Point', item[item.locationType].blng, item[item.locationType].blat), res => {
const {content: {poi_desc, address_detail: {province, city, district, town, street}}} = res
item.transferAddress = province + city + district + town + street + poi_desc;
locates[idx].transferAddress = province + city + district + town + street + poi_desc;
points.push(drawMarker(item, map, locates));
})
points.push(drawMarker(item, map, locates));
});
if (locates.length <= 0) {
return Toast("暂无有效定位点信息");
......@@ -552,6 +551,8 @@ export default defineComponent({
// offset: window.mapapi.invoke('Size', 22, 100)
}
);
setAddress();
setOnlineTime();
});
// mapapi.invoke('mapOpenInfoWindow', infoWindow, mapapi.invoke('markerGetPosition', marker))
// let infoWindow = new window.AMap.InfoWindow({
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!