91 lines
2.5 KiB
JavaScript
91 lines
2.5 KiB
JavaScript
"use strict";
|
|
const common_vendor = require("./common/vendor.js");
|
|
const utils_map = require("./utils/map.js");
|
|
if (!Array) {
|
|
const _easycom_uni_icons2 = common_vendor.resolveComponent("uni-icons");
|
|
_easycom_uni_icons2();
|
|
}
|
|
const _easycom_uni_icons = () => "./node-modules/@dcloudio/uni-ui/lib/uni-icons/uni-icons.js";
|
|
if (!Math) {
|
|
_easycom_uni_icons();
|
|
}
|
|
const _sfc_main = {
|
|
__name: "map-location",
|
|
props: ["lng", "lat", "height"],
|
|
emits: ["change"],
|
|
setup(__props, { emit: __emit }) {
|
|
var qqmapsdk = new common_vendor.QQMapWX({
|
|
key: utils_map.sdkKey
|
|
});
|
|
const {
|
|
lng,
|
|
lat,
|
|
height
|
|
} = __props;
|
|
const emit = __emit;
|
|
common_vendor.ref("mapRef");
|
|
let oMap = null;
|
|
const latitude = common_vendor.ref(lat);
|
|
const longitude = common_vendor.ref(lng);
|
|
const scale = common_vendor.ref(15);
|
|
const point = lng && lat ? [utils_map.addMarker(1, lng, lat, "point.png")] : null;
|
|
const markers = common_vendor.ref(point);
|
|
common_vendor.onMounted(() => {
|
|
oMap = utils_map.getMap("mapRef", common_vendor.getCurrentInstance());
|
|
});
|
|
const ontap = (e) => {
|
|
const {
|
|
detail: {
|
|
latitude: lat2,
|
|
longitude: lng2
|
|
}
|
|
} = e;
|
|
changPoint(lng2, lat2);
|
|
};
|
|
const getLoalcationPoint = () => {
|
|
utils_map.getLoalcation(oMap, (res) => {
|
|
const {
|
|
longitude: lng2,
|
|
latitude: lat2
|
|
} = res;
|
|
latitude.value = lat2;
|
|
longitude.value = lng2;
|
|
changPoint(lng2, lat2);
|
|
});
|
|
};
|
|
const changPoint = (lng2, lat2) => {
|
|
const arrPoint = markers.value;
|
|
let index = common_vendor.lodashExports.findIndex(arrPoint, {
|
|
id: 1
|
|
});
|
|
index = index == -1 ? arrPoint.length : index;
|
|
arrPoint[index] = utils_map.addMarker(1, lng2, lat2, "point.png");
|
|
markers.value = arrPoint;
|
|
utils_map.reverseGeocoder(qqmapsdk, lng2, lat2, (res) => {
|
|
emit("change", res);
|
|
}, (res) => {
|
|
});
|
|
};
|
|
return (_ctx, _cache) => {
|
|
return {
|
|
a: common_vendor.p({
|
|
["custom-prefix"]: "iconfont",
|
|
type: "icon-ebikedingwei2",
|
|
color: "#6f7777",
|
|
size: "16"
|
|
}),
|
|
b: common_vendor.o(getLoalcationPoint),
|
|
c: __props.height,
|
|
d: scale.value,
|
|
e: longitude.value,
|
|
f: latitude.value,
|
|
g: markers.value,
|
|
h: common_vendor.o(ontap),
|
|
i: __props.height
|
|
};
|
|
};
|
|
}
|
|
};
|
|
exports._sfc_main = _sfc_main;
|
|
//# sourceMappingURL=../.sourcemap/mp-weixin/map-location.js.map
|