{"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) {\n var geocoder = new AMap.Geocoder({\n city: \"010\" //城市设为北京,默认:“全国”\n });\n\n AMap.plugin('AMap.Geocoder', function () {\n var geocoder = new AMap.Geocoder({\n city: '010' // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode\n });\n\n var lnglat = [116.396574, 39.992706];\n geocoder.getAddress(lnglat, function (status, result) {\n if (status === 'complete' && result.info === 'OK') {\n // result为对应的地理位置详细信息\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","geocoder","Geocoder","city","lnglat","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) {\r\n\r\n var geocoder = new AMap.Geocoder({\r\n city: \"010\", //城市设为北京,默认:“全国”\r\n });\r\n\r\n\r\n AMap.plugin('AMap.Geocoder', function() {\r\n var geocoder = new AMap.Geocoder({\r\n city: '010' // city 指定进行编码查询的城市,支持传入城市名、adcode 和 citycode\r\n })\r\n\r\n var lnglat = [116.396574, 39.992706]\r\n\r\n geocoder.getAddress(lnglat, function(status, result) {\r\n if (status === 'complete' && result.info === 'OK') {\r\n // 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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