"use strict"; const common_vendor = require("../../../../common/vendor.js"); const pages_guide_markers = require("../../../../pages/guide/markers.js"); const pages_guide_routes = require("../../../../pages/guide/routes.js"); function AMapWX(a) { this.key = a.key; this.requestConfig = { key: a.key, s: "rsx", platform: "WXJS", appname: a.key, sdkversion: "1.2.0", logversion: "2.0" }; } AMapWX.prototype.getWxLocation = function(a, b) { common_vendor.index.getLocation({ type: "gcj02", success: function(a2) { var c = a2.longitude + "," + a2.latitude; common_vendor.index.setStorage({ key: "userLocation", data: c }), b(c); }, fail: function(c) { common_vendor.index.getStorage({ key: "userLocation", success: function(a2) { a2.data && b(a2.data); } }); } }); }; AMapWX.prototype.getRegeo = function(a) { function c(c2) { var d = b.requestConfig; common_vendor.index.request({ url: "https://restapi.amap.com/v3/geocode/regeo", data: { key: b.key, location: c2, extensions: "all", s: d.s, platform: d.platform, appname: b.key, sdkversion: d.sdkversion, logversion: d.logversion }, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { var d2, e, f, g, h, i, j, k, l; b2.data.status && "1" == b2.data.status ? (d2 = b2.data.regeocode, e = d2.addressComponent, f = [], g = "", d2 && d2.roads[0] && d2.roads[0].name && (g = d2.roads[0].name + "附近"), h = c2.split(",")[0], i = c2.split(",")[1], d2.pois && d2.pois[0] && (g = d2.pois[0].name + "附近", j = d2.pois[0].location, j && (h = parseFloat(j.split(",")[0]), i = parseFloat(j.split(",")[1]))), e.provice && f.push(e.provice), e.city && f.push(e.city), e.district && f.push( e.district ), e.streetNumber && e.streetNumber.street && e.streetNumber.number ? (f.push(e.streetNumber.street), f.push(e.streetNumber.number)) : (k = "", d2 && d2.roads[0] && d2.roads[0].name && (k = d2.roads[0].name), f.push( k )), f = f.join(""), l = [{ iconPath: a.iconPath, width: a.iconWidth, height: a.iconHeight, name: f, desc: g, longitude: h, latitude: i, id: 0, regeocodeData: d2 }], a.success(l)) : (a == null ? void 0 : a.fail) && a.fail({ errCode: b2.data.infocode, errMsg: b2.data.info }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); } var b = this; a.location ? c(a.location) : b.getWxLocation(a, function(a2) { c(a2); }); }; AMapWX.prototype.getWeather = function(a) { function d(d2) { var e2 = "base"; a.type && "forecast" == a.type && (e2 = "all"), common_vendor.index.request({ url: "https://restapi.amap.com/v3/weather/weatherInfo", data: { key: b.key, city: d2, extensions: e2, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { function c2(a2) { var b3 = { city: { text: "城市", data: a2.city }, weather: { text: "天气", data: a2.weather }, temperature: { text: "温度", data: a2.temperature }, winddirection: { text: "风向", data: a2.winddirection + "风" }, windpower: { text: "风力", data: a2.windpower + "级" }, humidity: { text: "湿度", data: a2.humidity + "%" } }; return b3; } var d3, e3; b2.data.status && "1" == b2.data.status ? b2.data.lives ? (d3 = b2.data.lives, d3 && d3.length > 0 && (d3 = d3[0], e3 = c2( d3 ), e3["liveData"] = d3, a.success(e3))) : b2.data.forecasts && b2.data.forecasts[0] && a.success({ forecast: b2.data.forecasts[0] }) : a.fail({ errCode: b2.data.infocode, errMsg: b2.data.info }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); } function e(e2) { common_vendor.index.request({ url: "https://restapi.amap.com/v3/geocode/regeo", data: { key: b.key, location: e2, extensions: "all", s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { var c2, e3; b2.data.status && "1" == b2.data.status ? (e3 = b2.data.regeocode, e3.addressComponent ? c2 = e3.addressComponent.adcode : e3.aois && e3.aois.length > 0 && (c2 = e3.aois[0].adcode), d(c2)) : a.fail({ errCode: b2.data.infocode, errMsg: b2.data.info }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); } var b = this, c = b.requestConfig; a.city ? d(a.city) : b.getWxLocation(a, function(a2) { e(a2); }); }; AMapWX.prototype.getPoiAround = function(a) { function d(d2) { var e = { key: b.key, location: d2, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.querytypes && (e["types"] = a.querytypes), a.querykeywords && (e["keywords"] = a.querykeywords), common_vendor.index.request({ url: "https://restapi.amap.com/v3/place/around", data: e, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { var c2, d3, e2, f; if (b2.data.status && "1" == b2.data.status) { if (b2 = b2.data, b2 && b2.pois) { for (c2 = [], d3 = 0; d3 < b2.pois.length; d3++) e2 = 0 == d3 ? a.iconPathSelected : a.iconPath, c2.push({ latitude: parseFloat(b2.pois[d3].location.split(",")[1]), longitude: parseFloat(b2.pois[d3].location.split(",")[0]), iconPath: e2, width: 22, height: 32, id: d3, name: b2.pois[d3].name, address: b2.pois[d3].address }); f = { markers: c2, poisData: b2.pois }, a.success(f); } } else a.fail({ errCode: b2.data.infocode, errMsg: b2.data.info }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); } var b = this, c = b.requestConfig; a.location ? d(a.location) : b.getWxLocation(a, function(a2) { d(a2); }); }; AMapWX.prototype.getStaticmap = function(a) { function f(b2) { c.push("location=" + b2), a.zoom && c.push("zoom=" + a.zoom), a.size && c.push("size=" + a.size), a.scale && c.push( "scale=" + a.scale ), a.markers && c.push("markers=" + a.markers), a.labels && c.push("labels=" + a.labels), a.paths && c.push("paths=" + a.paths), a.traffic && c.push("traffic=" + a.traffic); var e2 = d + c.join("&"); a.success({ url: e2 }); } var e, b = this, c = [], d = "https://restapi.amap.com/v3/staticmap?"; c.push("key=" + b.key), e = b.requestConfig, c.push("s=" + e.s), c.push( "platform=" + e.platform ), c.push("appname=" + e.appname), c.push("sdkversion=" + e.sdkversion), c.push("logversion=" + e.logversion), a.location ? f(a.location) : b.getWxLocation(a, function(a2) { f(a2); }); }; AMapWX.prototype.getInputtips = function(a) { var b = this, c = b.requestConfig, d = { key: b.key, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.location && (d["location"] = a.location), a.keywords && (d["keywords"] = a.keywords), a.type && (d["type"] = a.type), a.city && (d["city"] = a.city), a.citylimit && (d["citylimit"] = a.citylimit), common_vendor.index.request({ url: "https://restapi.amap.com/v3/assistant/inputtips", data: d, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { b2 && b2.data && b2.data.tips && a.success({ tips: b2.data.tips }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); }; AMapWX.prototype.getDrivingRoute = function(a) { var b = this, c = b.requestConfig, d = { key: b.key, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.origin && (d["origin"] = a.origin), a.destination && (d["destination"] = a.destination), a.strategy && (d["strategy"] = a.strategy), a.waypoints && (d["waypoints"] = a.waypoints), a.avoidpolygons && (d["avoidpolygons"] = a.avoidpolygons), a.avoidroad && (d["avoidroad"] = a.avoidroad), common_vendor.index.request({ url: "https://restapi.amap.com/v3/direction/driving", data: d, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { b2 && b2.data && b2.data.route && a.success({ paths: b2.data.route.paths, taxi_cost: b2.data.route.taxi_cost || "" }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); }; AMapWX.prototype.getWalkingRoute = function(a) { var b = this, c = b.requestConfig, d = { key: b.key, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.origin && (d["origin"] = a.origin), a.destination && (d["destination"] = a.destination), common_vendor.index.request({ url: "https://restapi.amap.com/v3/direction/walking", data: d, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { b2 && b2.data && b2.data.route && a.success({ paths: b2.data.route.paths }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); }; AMapWX.prototype.getTransitRoute = function(a) { var b = this, c = b.requestConfig, d = { key: b.key, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.origin && (d["origin"] = a.origin), a.destination && (d["destination"] = a.destination), a.strategy && (d["strategy"] = a.strategy), a.city && (d["city"] = a.city), a.cityd && (d["cityd"] = a.cityd), common_vendor.index.request({ url: "https://restapi.amap.com/v3/direction/transit/integrated", data: d, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { if (b2 && b2.data && b2.data.route) { var c2 = b2.data.route; a.success({ distance: c2.distance || "", taxi_cost: c2.taxi_cost || "", transits: c2.transits }); } }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); }; AMapWX.prototype.getRidingRoute = function(a) { var b = this, c = b.requestConfig, d = { key: b.key, s: c.s, platform: c.platform, appname: b.key, sdkversion: c.sdkversion, logversion: c.logversion }; a.origin && (d["origin"] = a.origin), a.destination && (d["destination"] = a.destination), common_vendor.index.request({ url: "https://restapi.amap.com/v4/direction/bicycling", data: d, method: "GET", header: { "content-type": "application/json" }, success: function(b2) { b2 && b2.data && b2.data.data && a.success({ paths: b2.data.data.paths }); }, fail: function(b2) { a.fail({ errCode: "0", errMsg: b2.errMsg || "" }); } }); }; const _sfc_main = { name: "amap", props: { longitude: { type: String, default: "" }, latitude: { type: String, default: "" }, mapKey: { require: true, type: String, default: "" }, marker: { type: Object, default: () => { } }, disable: { type: Boolean, default: false }, isPolygons: { type: Boolean, default: false }, polygons: { type: Array, default: () => [] }, top: { type: [String, Number], default: 30 }, isCustomBar: { type: Boolean, default: false } }, data() { var _a, _b, _c; return { statusBarH: 0, customBarH: 0, addressMap: "", searchValue: "", markers: [], amapPlugin: null, key: (_a = this.$props) == null ? void 0 : _a.mapKey, //高德地图key https://console.amap.com/dev/key/app 服务平台选择微信小程序 center_lat: (_b = this.$props) == null ? void 0 : _b.latitude, center_lon: (_c = this.$props) == null ? void 0 : _c.longitude, center_scale: 16, regeocodeData: {}, searchList: [], markerShow: [ { id: "scenic", name: "景点", show: false }, { id: "toilet", name: "厕所", show: false }, { id: "parking", name: "停车", show: false }, { id: "food", name: "餐饮", show: false }, { id: "shop", name: "商店", show: false }, { id: "hospital", name: "医院", show: false }, { id: "police", name: "警室", show: false } ], isPolylines: false, ploylines: [], route: null, currentRoute: { routeid: null }, currentRoutePointIndex: null }; }, onShow() { if (!this._mapContext) { this.$nextTick(() => { this._mapContext = common_vendor.index.createMapContext("map", this); }); } }, created() { this.init(); let self = this; common_vendor.index.getSystemInfo({ success: function(e) { var _a, _b; self.statusBarH = e.statusBarHeight + 5; if ((_b = (_a = common_vendor.index).getMenuButtonBoundingClientRect) == null ? void 0 : _b.call(_a)) { let custom = common_vendor.index.getMenuButtonBoundingClientRect(); self.customBarH = custom.height + 5; } else { self.customBarH = 30; } } }); }, methods: { changeMarkers() { var _a; this.markers[0] = { ...(_a = this.$props) == null ? void 0 : _a.marker, longitude: this.center_lon, latitude: this.center_lat }; }, init() { var _a, _b; this.amapPlugin = new AMapWX({ key: this.key }); const detail = { longitude: (_a = this.$props) == null ? void 0 : _a.longitude, latitude: (_b = this.$props) == null ? void 0 : _b.latitude }; if (!detail.latitude || !detail.longitude) { const _this = this; common_vendor.index.getLocation({ type: "gcj02", isHighAccuracy: true, success: (data) => { detail.latitude = data.latitude; detail.longitude = data.longitude; _this.getCurrentLocation({ detail }); } }); } else { this.getCurrentLocation({ detail }); } }, poitap(e) { common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:769", e); }, //点击地图 getCurrentLocation(e) { this.searchValue = ""; const { latitude, longitude } = e.detail; common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:778", longitude); common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:779", latitude); if (!latitude || !longitude) return; this.getRegeo([longitude, latitude], (pois) => { this.searchList = pois; }); }, getInputtips() { this.amapPlugin.getInputtips({ key: this.key, keywords: this.searchValue, location: this.center_lon + "," + this.center_lat, success: (data) => { this.searchList = data.tips.filter((i) => { var _a; return ((_a = i == null ? void 0 : i.id) == null ? void 0 : _a.length) && (i == null ? void 0 : i.location); }); } }); }, getRegeo(coordinate, fn) { this.center_lat = coordinate[1]; this.center_lon = coordinate[0]; this.changeMarkers(); this.amapPlugin.getRegeo({ location: this.center_lon + "," + this.center_lat, success: (data) => { const { regeocodeData } = data[0]; this.addressMap = regeocodeData.formatted_address; this.regeocodeData = regeocodeData; this.$emit("changeMarker", this.getConfirmData()); fn && fn(regeocodeData.pois); } }); }, //搜索关键字 searchMap() { this.getInputtips(); }, getCurrentSingleLocation(data) { let coordinate = data.location.split(","); this.searchValue = data.name; this.getRegeo(coordinate); }, close() { this.$emit("confirm"); }, getConfirmData() { var _a; const { pois, addressComponent: { province, district, township } } = this.regeocodeData; const title = ((_a = pois == null ? void 0 : pois[0]) == null ? void 0 : _a.name) || province + district + township; return { ...this.regeocodeData, title, latitude: this.center_lat, longitude: this.center_lon, address: this.addressMap }; }, submit(e) { if (this.$props.disable) { return; } if (!this.addressMap) { return; } if (JSON.stringify(this.regeocodeData) != "{}") { this.$emit("confirm", this.getConfirmData()); } }, gotoHome() { this.checkMapContext(); common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:857", this._mapContext); this.center_lat = 31.0125237588488; this.center_lon = 112.1783132134475; this.center_scale = 16; this._mapContext.moveToLocation({ latitude: 31.0125237588488, longitude: 112.1783132134475 }); this.addMarkers(); }, checkMapContext() { if (!this._mapContext) { this._mapContext = common_vendor.index.createMapContext("map", this); } }, toggleMarker(item) { item.show = !item.show; this.addMarkers(); }, closeShowRoute() { this.isPolylines = false; this.addMarkers(); }, onRoutPointClick(item, index) { common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:894", item); this.currentRoutePointIndex = index; this.checkMapContext(); this._mapContext.moveToLocation({ latitude: item.latitude, longitude: item.longitude }); }, addMarkers() { const _markers = []; common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:902", pages_guide_markers.mapMarkers); pages_guide_markers.mapMarkers.forEach((group) => { var _a; const type = group.type; if ((_a = this.markerShow.find((item) => item.id === type)) == null ? void 0 : _a.show) { const { iconPath, width, height, label, pois } = group; pois.forEach((poi, index) => { _markers.push({ id: poi.id, iconPath, width, height, longitude: poi.longitude, latitude: poi.latitude, label: { ...label, content: poi.name || `${type} ${index + 1}` } }); }); } }); this.checkMapContext(); this._mapContext.addMarkers({ markers: _markers, clear: true, complete(res) { common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:930", "addMarkers", res); } }); }, showRoute(routeid) { this.isPolylines = false; this.currentRoutePointIndex = null; this.checkMapContext(); const route = pages_guide_routes.mapRoutes.find((r) => r.routeid === routeid); this.currentRoute = route; const allRouteMarkerid = []; pages_guide_routes.mapRoutes.forEach((route2) => { allRouteMarkerid.push(route2.markerid); }); if (!route) { common_vendor.index.__f__("error", "at uni_modules/atl-map/components/amap/amap.vue:946", "Route not found:", routeid); return; } common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:949", route); const pois = route.pois; if (!pois || pois.length === 0) { common_vendor.index.__f__("error", "at uni_modules/atl-map/components/amap/amap.vue:952", "No POIs found for route:", routeid); return; } try { this._mapContext.removeMarkers({ markerIds: allRouteMarkerid }); } catch (err) { common_vendor.index.__f__("warn", "at uni_modules/atl-map/components/amap/amap.vue:960", "删除 marker 时出现异常:", err); } const routeMarker = { id: route.markerid, iconPath: route.iconPath, width: route.width, height: route.height, longitude: pois[0].longitude, latitude: pois[0].latitude }; const routePointMarker = route.pois.map((poi, index) => ({ id: index + 1, // 从0开始的唯一ID iconPath: `https://farm.evcc.top/Uploads/yuanboyuan/maps/badge_${index + 1}.png`, // 替换 {} 为索引+1 width: 15, height: 15, longitude: poi.longitude, latitude: poi.latitude, label: { width: 60, height: 30, borderWidth: 1, borderRadius: 10, bgColor: "#333333", color: "#ffffff", content: poi.name, fontSize: 12, textAlign: "center" } })); routePointMarker.push(routeMarker); common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:993", routePointMarker); this.isPolylines = true; this.ploylines = [ { name: route.routename, arrowLine: true, color: "#27bd09e6", id: route.routeid, width: 3, points: route.pois } ]; this._mapContext.addMarkers({ //markers: [routeMarker], markers: routePointMarker, clear: true, success: () => { common_vendor.index.__f__("log", "at uni_modules/atl-map/components/amap/amap.vue:1012", "新路线 marker 已添加"); this._mapContext.moveAlong({ markerId: route.markerid, path: route.pois, duration: route.duration, autoRotate: true, fail: (err) => { this._mapContext.moveAlong({ markerId: route.markerid, path: route.pois, duration: route.duration, autoRotate: true }); } }); }, fail: (err) => common_vendor.index.__f__("error", "at uni_modules/atl-map/components/amap/amap.vue:1029", "添加 marker 失败:", err) }); } } }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return common_vendor.e({ a: common_vendor.o((...args) => $options.gotoHome && $options.gotoHome(...args)), b: common_vendor.f($data.markerShow, (item, index, i0) => { return { a: `https://farm.evcc.top/Uploads/yuanboyuan/maps/${item.id}${item.show ? "" : "_"}.png`, b: common_vendor.t(item.name), c: item.id, d: common_vendor.o(($event) => $options.toggleMarker(item), item.id) }; }), c: `https://farm.evcc.top/Uploads/yuanboyuan/maps/route${$data.currentRoute.routeid == "route1" ? "" : "_"}.png`, d: common_vendor.o(($event) => $options.showRoute("route1")), e: `https://farm.evcc.top/Uploads/yuanboyuan/maps/route${$data.currentRoute.routeid == "route2" ? "" : "_"}.png`, f: common_vendor.o(($event) => $options.showRoute("route2")), g: `https://farm.evcc.top/Uploads/yuanboyuan/maps/route${$data.currentRoute.routeid == "route3" ? "" : "_"}.png`, h: common_vendor.o(($event) => $options.showRoute("route3")), i: $data.center_lat, j: $data.center_lon, k: $data.center_scale, l: $data.markers, m: common_vendor.o((...args) => $options.getCurrentLocation && $options.getCurrentLocation(...args)), n: $props.isPolygons ? $props.polygons : [], o: $data.isPolylines ? $data.ploylines : [], p: common_vendor.o((...args) => $options.poitap && $options.poitap(...args)), q: $data.isPolylines }, $data.isPolylines ? { r: common_vendor.o((...args) => $options.closeShowRoute && $options.closeShowRoute(...args)), s: common_vendor.f($data.currentRoute.pois, (item, index, i0) => { return common_vendor.e({ a: `https://farm.evcc.top/Uploads/yuanboyuan/maps/badge_${index + 1}.png`, b: common_vendor.t(item.name), c: index === $data.currentRoutePointIndex ? "bold" : "normal", d: index === $data.currentRoutePointIndex ? "#0000FF" : "#000", e: common_vendor.o(($event) => $options.onRoutPointClick(item, index), index), f: index < $data.currentRoute.pois.length - 1 }, index < $data.currentRoute.pois.length - 1 ? {} : {}, { g: index }); }) } : {}, { t: common_vendor.s($props.isCustomBar && { height: $data.customBarH + "px", paddingTop: $data.statusBarH + "px", backgroundColor: "transparent", top: $props.top + "px" }) }); } const Component = /* @__PURE__ */ common_vendor._export_sfc(_sfc_main, [["render", _sfc_render], ["__scopeId", "data-v-72149856"]]); wx.createComponent(Component); //# sourceMappingURL=../../../../../.sourcemap/mp-weixin/uni_modules/atl-map/components/amap/amap.js.map