{"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 reject(result);\n }\n });\n });\n });\n}\n\n// 逆地址解析,根据经纬度获取详细地址\nexport function getAddress(mapContext, 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 resolve(result);\n } else {\n console.log(result);\n alert(JSON.stringify(result));\n }\n });\n });\n });\n}\n\n// 输入提示\nexport function searchFun(mapContext, cityCode, keyword) {\n return new Promise((resolve, reject) => {\n mapContext.plugin('AMap.AutoComplete', function () {\n var autoOptions = {\n city: cityCode || '全国'\n };\n // 实例化AutoComplete\n var autoComplete = new AMap.AutoComplete(autoOptions);\n // 根据关键字进行搜索\n autoComplete.search(keyword, function (status, result) {\n // 搜索成功时,result即是对应的匹配数据\n if (result.info == 'OK') {\n resolve(result.tips);\n } else {\n reject(result);\n }\n });\n });\n });\n}\n\n// 路径规划\nexport function getRoad(mapContext, startLng, startLat, endLng, endLat) {\n return new Promise((resolve, reject) => {\n mapContext.plugin('AMap.Driving', function () {\n let driving = new AMap.Driving({\n // 驾车路线规划策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式\n // policy: AMap.DrivingPolicy.LEAST_TIME,\n // map: mapContext\n });\n let startLngLat = [startLng, startLat];\n let endLngLat = [endLng, endLat];\n driving.search(startLngLat, endLngLat, function (status, result) {\n // 未出错时,result即是对应的路线规划方案\n if (status === 'complete') {\n resolve(result);\n } else {\n reject(result);\n }\n });\n });\n });\n}\nfunction drawRoute(route, map) {\n let path = parseRouteToPath(route);\n let routeLine = new AMap.Polyline({\n path: path,\n isOutline: true,\n outlineColor: '#ffeeee',\n borderWeight: 2,\n strokeWeight: 5,\n strokeOpacity: 0.9,\n strokeColor: '#0091ff',\n lineJoin: 'round'\n });\n map.add(routeLine);\n}","map":{"version":3,"names":["getLocal","mapContext","Promise","resolve","reject","plugin","geolocation","AMap","Geolocation","enableHighAccuracy","timeout","offset","zoomToAccuracy","position","getCurrentPosition","status","result","getAddress","lnglat","geocoder","Geocoder","info","console","log","alert","JSON","stringify","searchFun","cityCode","keyword","autoOptions","city","autoComplete","AutoComplete","search","tips","getRoad","startLng","startLat","endLng","endLat","driving","Driving","startLngLat","endLngLat","drawRoute","route","map","path","parseRouteToPath","routeLine","Polyline","isOutline","outlineColor","borderWeight","strokeWeight","strokeOpacity","strokeColor","lineJoin","add"],"sources":["C:/Users/zhouxueli/Desktop/scheduling-app/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 reject(result)\r\n }\r\n });\r\n })\r\n })\r\n}\r\n\r\n// 逆地址解析,根据经纬度获取详细地址\r\nexport function getAddress(mapContext, 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 resolve(result)\r\n } else {\r\n console.log(result)\r\n alert(JSON.stringify(result))\r\n }\r\n })\r\n })\r\n })\r\n}\r\n\r\n// 输入提示\r\nexport function searchFun(mapContext, cityCode, keyword) {\r\n return new Promise((resolve, reject) => {\r\n mapContext.plugin('AMap.AutoComplete', function(){\r\n var autoOptions = {\r\n city: cityCode || '全国',\r\n };\r\n // 实例化AutoComplete\r\n var autoComplete= new AMap.AutoComplete(autoOptions);\r\n // 根据关键字进行搜索\r\n autoComplete.search(keyword, function(status, result) {\r\n // 搜索成功时,result即是对应的匹配数据\r\n if(result.info == 'OK') {\r\n resolve(result.tips)\r\n } else {\r\n reject(result)\r\n }\r\n })\r\n })\r\n })\r\n}\r\n\r\n// 路径规划\r\nexport function getRoad( mapContext, startLng, startLat, endLng, endLat ) {\r\n return new Promise((resolve, reject) => {\r\n mapContext.plugin('AMap.Driving', function() {\r\n let driving = new AMap.Driving({\r\n // 驾车路线规划策略,AMap.DrivingPolicy.LEAST_TIME是最快捷模式\r\n // policy: AMap.DrivingPolicy.LEAST_TIME,\r\n // map: mapContext\r\n })\r\n\r\n let startLngLat = [startLng, startLat]\r\n let endLngLat = [endLng, endLat]\r\n\r\n driving.search(startLngLat, endLngLat, function (status, result) {\r\n // 未出错时,result即是对应的路线规划方案\r\n if (status === 'complete') {\r\n resolve(result)\r\n } else {\r\n reject(result)\r\n }\r\n })\r\n })\r\n })\r\n}\r\n\r\n\r\nfunction drawRoute(route, map) {\r\n let path = parseRouteToPath(route)\r\n\r\n let routeLine = new AMap.Polyline({\r\n path: path,\r\n isOutline: true,\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