{"ast":null,"code":"// 获取定位, 返回 经纬度\nexport function getLocal(mapContext) {\n return new Promise((resolve, reject) => {\n mapContext.plugin('AMap.Geolocation', function () {\n let geolocation = new AMap.Geolocation({\n enableHighAccuracy: true,\n // 是否使用高精度定位,默认:true\n timeout: 10000,\n // 设置定位超时时间,默认:无穷大\n offset: [10, 20],\n // 定位按钮的停靠位置的偏移量\n zoomToAccuracy: true,\n // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false\n position: 'RB' // 定位按钮的排放位置, RB表示右下\n });\n\n geolocation.getCurrentPosition(function (status, result) {\n if (status == 'complete') {\n resolve(result.position);\n } else {\n alert(JSON.stringify(result));\n reject(result);\n }\n });\n });\n });\n}\n\n// 逆地址解析,根据经纬度获取详细地址\nexport function getAddress(mapContext, lnglat) {\n alert(JSON.stringify(lnglat));\n return new Promise((resolve, reject) => {\n mapContext.plugin('AMap.Geocoder', function () {\n let geocoder = new AMap.Geocoder({\n // city: \"010\", //城市设为北京,默认:“全国”\n });\n geocoder.getAddress(lnglat, function (status, result) {\n if (status === 'complete' && result.info === 'OK') {\n // result为对应的地理位置详细信息\n alert(JSON.stringify(result));\n resolve(result);\n } else {\n alert(JSON.stringify(result));\n }\n });\n });\n });\n}","map":{"version":3,"names":["getLocal","mapContext","Promise","resolve","reject","plugin","geolocation","AMap","Geolocation","enableHighAccuracy","timeout","offset","zoomToAccuracy","position","getCurrentPosition","status","result","alert","JSON","stringify","getAddress","lnglat","geocoder","Geocoder","info"],"sources":["E:/work/sino/sino-h5/src/utils/map.js"],"sourcesContent":["// 获取定位, 返回 经纬度\r\nexport function getLocal(mapContext) {\r\n return new Promise((resolve, reject) => {\r\n mapContext.plugin('AMap.Geolocation', function () {\r\n let geolocation = new AMap.Geolocation({\r\n enableHighAccuracy: true, // 是否使用高精度定位,默认:true\r\n timeout: 10000, // 设置定位超时时间,默认:无穷大\r\n offset: [10, 20], // 定位按钮的停靠位置的偏移量\r\n zoomToAccuracy: true, // 定位成功后调整地图视野范围使定位位置及精度范围视野内可见,默认:false\r\n position: 'RB' // 定位按钮的排放位置, RB表示右下\r\n })\r\n\r\n geolocation.getCurrentPosition(function(status, result){\r\n if(status == 'complete'){\r\n resolve(result.position)\r\n }else{\r\n alert(JSON.stringify(result))\r\n reject(result)\r\n }\r\n });\r\n })\r\n })\r\n}\r\n\r\n// 逆地址解析,根据经纬度获取详细地址\r\nexport function getAddress(mapContext, lnglat) {\r\n alert(JSON.stringify(lnglat))\r\n return new Promise((resolve, reject) => {\r\n mapContext.plugin('AMap.Geocoder', function () {\r\n let geocoder = new AMap.Geocoder({\r\n // city: \"010\", //城市设为北京,默认:“全国”\r\n });\r\n\r\n geocoder.getAddress(lnglat, function(status, result) {\r\n if (status === 'complete' && result.info === 'OK') {\r\n // result为对应的地理位置详细信息\r\n alert(JSON.stringify(result))\r\n resolve(result)\r\n } else {\r\n alert(JSON.stringify(result))\r\n }\r\n })\r\n })\r\n })\r\n}\r\n"],"mappings":"AAAA;AACA,OAAO,SAASA,QAAQA,CAACC,UAAU,EAAE;EACnC,OAAO,IAAIC,OAAO,CAAC,CAACC,OAAO,EAAEC,MAAM,KAAK;IACtCH,UAAU,CAACI,MAAM,CAAC,kBAAkB,EAAE,YAAY;MAChD,IAAIC,WAAW,GAAG,IAAIC,IAAI,CAACC,WAAW,CAAC;QACrCC,kBAAkB,EAAE,IAAI;QAAE;QAC1BC,OAAO,EAAE,KAAK;QAAE;QAChBC,MAAM,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;QAAG;QACnBC,cAAc,EAAE,IAAI;QAAG;QACvBC,QAAQ,EAAE,IAAI,CAAC;MACjB,CAAC,CAAC;;MAEFP,WAAW,CAACQ,kBAAkB,CAAC,UAASC,MAAM,EAAEC,MAAM,EAAC;QACrD,IAAGD,MAAM,IAAI,UAAU,EAAC;UACtBZ,OAAO,CAACa,MAAM,CAACH,QAAQ,CAAC;QAC1B,CAAC,MAAI;UACHI,KAAK,CAACC,IAAI,CAACC,SAAS,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