"use strict";
const common_vendor = require("../vendor.js");
function getMapLbs() {
  const AMAP_KEY = "be262c006216c542747fce766130cee3";
  return new Promise((resolve, reject) => {
    common_vendor.index.getLocation({
      type: "gcj02",
      altitude: true,
      isHighAccuracy: true,
      success(res) {
        console.log(res, "经纬度");
        const url = `https://restapi.amap.com/v3/geocode/regeo?location=${res.longitude},${res.latitude}&key=${AMAP_KEY}`;
        common_vendor.index.request({
          url,
          method: "GET",
          success(res2) {
            var _a;
            console.log(res2, "address");
            resolve((_a = res2 == null ? void 0 : res2.data) == null ? void 0 : _a.regeocode);
          },
          fail(res2) {
            resolve({ address: "拒绝定位" });
            console.error("获取地址失败:", res2);
            common_vendor.index.showModal({
              title: "提示",
              content: "请先允许定位！",
              success: function(res3) {
                if (res3.confirm) {
                  common_vendor.index.openSetting();
                  console.log("用户点击确定");
                } else if (res3.cancel) {
                  console.log("用户点击取消");
                }
              }
            });
          }
        });
      },
      fail(e) {
        console.log("拒绝定位", e);
      }
    });
  });
}
exports.getMapLbs = getMapLbs;
