1 |
- import{U as y,d as P,O as k,V as O,o as C,a as z,g as I,R as x,W as N}from"./index-1d4a9afa.js";import{M as R}from"./index-6b314488.js";const T={};var b={},B={get exports(){return b},set exports(A){b=A}};(function(A,a){(function(M,L){A.exports=L()})(y,function(){function M(n){var l=[];return n.AMapUI&&l.push(L(n.AMapUI)),n.Loca&&l.push(h(n.Loca)),Promise.all(l)}function L(n){return new Promise(function(l,t){var u=[];if(n.plugins)for(var i=0;i<n.plugins.length;i+=1)s.AMapUI.plugins.indexOf(n.plugins[i])==-1&&u.push(n.plugins[i]);if(o.AMapUI===e.failed)t("前次请求 AMapUI 失败");else if(o.AMapUI===e.notload){o.AMapUI=e.loading,s.AMapUI.version=n.version||s.AMapUI.version,i=s.AMapUI.version;var p=document.body||document.head,c=document.createElement("script");c.type="text/javascript",c.src="https://webapi.amap.com/ui/"+i+"/main.js",c.onerror=function(r){o.AMapUI=e.failed,t("请求 AMapUI 失败")},c.onload=function(){if(o.AMapUI=e.loaded,u.length)window.AMapUI.loadUI(u,function(){for(var r=0,g=u.length;r<g;r++){var f=u[r].split("/").slice(-1)[0];window.AMapUI[f]=arguments[r]}for(l();d.AMapUI.length;)d.AMapUI.splice(0,1)[0]()});else for(l();d.AMapUI.length;)d.AMapUI.splice(0,1)[0]()},p.appendChild(c)}else o.AMapUI===e.loaded?n.version&&n.version!==s.AMapUI.version?t("不允许多个版本 AMapUI 混用"):u.length?window.AMapUI.loadUI(u,function(){for(var r=0,g=u.length;r<g;r++){var f=u[r].split("/").slice(-1)[0];window.AMapUI[f]=arguments[r]}l()}):l():n.version&&n.version!==s.AMapUI.version?t("不允许多个版本 AMapUI 混用"):d.AMapUI.push(function(r){r?t(r):u.length?window.AMapUI.loadUI(u,function(){for(var g=0,f=u.length;g<f;g++){var w=u[g].split("/").slice(-1)[0];window.AMapUI[w]=arguments[g]}l()}):l()})})}function h(n){return new Promise(function(l,t){if(o.Loca===e.failed)t("前次请求 Loca 失败");else if(o.Loca===e.notload){o.Loca=e.loading,s.Loca.version=n.version||s.Loca.version;var u=s.Loca.version,i=s.AMap.version.startsWith("2"),p=u.startsWith("2");if(i&&!p||!i&&p)t("JSAPI 与 Loca 版本不对应!!");else{i=s.key,p=document.body||document.head;var c=document.createElement("script");c.type="text/javascript",c.src="https://webapi.amap.com/loca?v="+u+"&key="+i,c.onerror=function(r){o.Loca=e.failed,t("请求 AMapUI 失败")},c.onload=function(){for(o.Loca=e.loaded,l();d.Loca.length;)d.Loca.splice(0,1)[0]()},p.appendChild(c)}}else o.Loca===e.loaded?n.version&&n.version!==s.Loca.version?t("不允许多个版本 Loca 混用"):l():n.version&&n.version!==s.Loca.version?t("不允许多个版本 Loca 混用"):d.Loca.push(function(r){r?t(r):t()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var e;(function(n){n.notload="notload",n.loading="loading",n.loaded="loaded",n.failed="failed"})(e||(e={}));var s={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:e.notload,AMapUI:e.notload,Loca:e.notload},d={AMap:[],AMapUI:[],Loca:[]},v=[],m=function(n){typeof n=="function"&&(o.AMap===e.loaded?n(window.AMap):v.push(n))};return{load:function(n){return new Promise(function(l,t){if(o.AMap==e.failed)t("");else if(o.AMap==e.notload){var u=n.key,i=n.version,p=n.plugins;u?(window.AMap&&location.host!=="lbs.amap.com"&&t("禁止多种API加载方式混用"),s.key=u,s.AMap.version=i||s.AMap.version,s.AMap.plugins=p||s.AMap.plugins,o.AMap=e.loading,i=document.body||document.head,window.___onAPILoaded=function(r){if(delete window.___onAPILoaded,r)o.AMap=e.failed,t(r);else for(o.AMap=e.loaded,M(n).then(function(){l(window.AMap)}).catch(t);v.length;)v.splice(0,1)[0]()},p=document.createElement("script"),p.type="text/javascript",p.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+s.AMap.version+"&key="+u+"&plugin="+s.AMap.plugins.join(","),p.onerror=function(r){o.AMap=e.failed,t(r)},i.appendChild(p)):t("请填写key")}else if(o.AMap==e.loaded)if(n.key&&n.key!==s.key)t("多个不一致的 key");else if(n.version&&n.version!==s.AMap.version)t("不允许多个版本 JSAPI 混用");else{if(u=[],n.plugins)for(i=0;i<n.plugins.length;i+=1)s.AMap.plugins.indexOf(n.plugins[i])==-1&&u.push(n.plugins[i]);u.length?window.AMap.plugin(u,function(){M(n).then(function(){l(window.AMap)}).catch(t)}):M(n).then(function(){l(window.AMap)}).catch(t)}else if(n.key&&n.key!==s.key)t("多个不一致的 key");else if(n.version&&n.version!==s.AMap.version)t("不允许多个版本 JSAPI 混用");else{var c=[];if(n.plugins)for(i=0;i<n.plugins.length;i+=1)s.AMap.plugins.indexOf(n.plugins[i])==-1&&c.push(n.plugins[i]);m(function(){c.length?window.AMap.plugin(c,function(){M(n).then(function(){l(window.AMap)}).catch(t)}):M(n).then(function(){l(window.AMap)}).catch(t)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,s={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},o={AMap:e.notload,AMapUI:e.notload,Loca:e.notload},d={AMap:[],AMapUI:[],Loca:[]}}}})})(B);const D=b,E="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAcCAMAAACnDzTfAAABHVBMVEUAAAADtKj///////////8Ktqv2/Pz////5/v3s+vnI7+z////c9fO+6+klvrSm5eFWzMX////////////////////////0/PwevLISuK7O8e7k9/Z11tC86+i46ueP3dlDx7/////////////////////////////////////////////////////////8/v7o+PczwrkwwbjH7uyB2dRYzcVhz8hRysNQysNHx8Ce4t5bzcaQ3tlp0cv///////////////////////////////////////////////////////8Asqf////1/Pvu+vnA7Oma4NspvrXp+Pff9fPa8/LG7eus5eJ21c9r0sxn0cpXzMU3wrkivLIWuK7c5d5VAAAATHRSTlMA/GsT1vr58Pn39/b29vbz8d2mPy8b+vf39/b09PPy8vLj2MWjkH9oUEU6JyAKBfv39fXz8/Py8vLy8fHv7+zRvbKrnJV8c19JNSoNw2x7SgAAAS1JREFUKM9tked2wjAMRh0IYe8NZVM2dO+9lz+ge/f9H6PEPsF2yP0l+x5LskQk7m87yTRx4K7phUm95bYZdwJAMVwOGIDXpah+HL5KhM7QqiUgMRIqXUMhRy1iBhLCNbDhoYI1A/O0N/DnqUwMXqshHdtUpYQrrlLwa+zm++3l/YlFe9C5cyHKLr4wY/LLuvWBJ13GEnPPMHlkcQE95i5wZB7/wJgyF0ZXeTeR3gWQVOp9mGrMm8kirfb5+Tqe/rCoivj8f1tUJYwW4bRR1BS1K+Yy0rEpK88qxJqSWFmXXBQNIrhEyCNNOtiX3LCOfUvlslAXnwrigCstgDOi0oYvwlwFNTex0eQld5DpETvDE5QpjRi4JosMjnGYD+GcONHNANAfiCOdePB0QAT/0uBtieUrtt8AAAAASUVORK5CYII=",S="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABsAAAAcCAMAAACnDzTfAAABIFBMVEUAAAD/XFj/////////////+fn/////8/P/////////+Pj/ZGD/////cm//1dX/xcT/t7X/kY//////////////////////X1v/2tr/1NP/bWr/6ur/5+f/4N//+vr/enf/pqT/0tH/lJH/joz//////////////////////////////////////////////////Pz/9/f/ZmP/3t3/29r/rqz/8PD/mZb/iIX/hoP/wcD/hYL/npz/////////////////////////////////////////////////////////////////////////Wlb/////9PT/6ej/1tX/vbz/npz/dHH/8fD/2tn/ycj/pqT/ko//fXr/cGz/aGT/XFg2JTGLAAAAT3RSTlMA/NZqE/3796UE+vr29vPz8fF+QS8bC/v5+Pf29vb19fTy8vLx7+Pc2cWQbUg6JyD29vX08/Py8vLy8fHv7N7RvbKroZyVc2dfUVA9NSoSehyD/QAAATZJREFUKM9tked6gkAQRRcUxF4Q7BoTa2zpvffOVWN6ef+3SBiCLIbza3bPt7t3dphD8L57o2rMg7vTOkxaKf+MeVAAbOSq2TJQ87lU/wBSImr8ImzHACXoKK2BUt6wSYagOK6NtYzhUAlheu0VAmGDJ4maHUjEpuEmhpSl0ggItPP+Mnp9omoLouU6iNPGBACGn5R2Cdali5gj9wyTR6pL6JE7w565/AIxJpdDlz/3PeTOZXFLzvf33pupJAojlKG5c05G0viDql00p/3Ne/VHXKIguNQC6n57qCLWeRUOoMNsVMgVzsXR5oZ0jmKG++lInznoLezYKr8M9+DTETursIpj5sYHKUougQZl5FFQCJvxZbnHZtEPURWMaAgX7D+DfSRWijhhXqgyAFFnnlw3I0cDbv0DsZxwvZH42EwAAAAASUVORK5CYII=",q=P({name:"amap-gps",setup(){const A=N(),a=k({attendance_range:1e3,lnglat:[],address:"",signInLongitudeLatitude:[],signOutLongitudeLatitude:[],signInMark:null,signOutMark:null,addressMark:null}),M=A.query.sLngLat;A.query.sLngLat&&(a.lnglat=M.split(","));const L=A.query.inLngLat;A.query.inLngLat&&(a.signInLongitudeLatitude=L.split(","));const h=A.query.outLngLat;A.query.outLngLat&&(a.signOutLongitudeLatitude=h.split(","));const e=O(null),s=()=>{D.load({key:"501e5bfaf7cfc5d3d53a9a4d9466d8b9",version:"2.0",plugins:["AMap.ToolBar","AMap.Driving"],AMapUI:{version:"1.1",plugins:[]},Loca:{version:"2.0.0"}}).then(o=>{let d=null;e.value=new o.Map("gpsContainer",{resizeEnable:!0,zoom:16,zooms:[2,22]}),o.plugin(["AMap.Geocoder","AMap.GeometryUtil"],function(){if(a.lnglat&&a.lnglat.length>0){e.value.setCenter(a.lnglat,!0),m(),v(a.lnglat,"教学点","addressMark");const l=new o.Circle({center:new o.LngLat(...a.lnglat),radius:a.attendance_range,strokeColor:"#00B2A7",strokeOpacity:1,strokeWeight:2,fillColor:"#A3FFF9",fillOpacity:.14});e.value.add(l),e.value.setFitView()}a.signInLongitudeLatitude&&a.signInLongitudeLatitude.length>0&&(console.log("signInLongitudeLatitude",a.signInLongitudeLatitude),v(a.signInLongitudeLatitude,"签到点","signInMark")),a.signOutLongitudeLatitude&&a.signOutLongitudeLatitude.length>0&&(console.log("signOutLongitudeLatitude",a.signOutLongitudeLatitude),v(a.signOutLongitudeLatitude,"签退点","signOutMark")),console.log(a,"selectMapAddress"),a.signInMark&&a.addressMark&&(n(a.addressMark,a.signInMark,"top"),console.log("连线 设置签到点与教学点的距离")),a.signOutMark&&a.addressMark&&(n(a.addressMark,a.signOutMark,"bottom"),console.log("连线 设置签退点与教学点的距离"))});function v(l,t,u){const i=new o.Icon({size:[27,28],image:E,imageSize:[27,28]});d=new o.Marker({icon:i,anchor:"bottom-center",position:new o.LngLat(...l),title:t}),d.setLabel({content:`${t}`,direction:"top",offset:[0,-2]}),a[u]=d,d.setMap(e),e.value.add(d)}function m(){d&&(d.setMap(null),d=null)}function n(l,t,u){const i=l.getPosition(),p=t.getPosition(),c=i.divideBy(2).add(p.divideBy(2)),r=Math.round(i.distance(p)),g=[i,p],f=r>a.attendance_range?"#FF5A56":"#01C1B5";r>a.attendance_range&&(t.dom.classList.add("myClassM2"),t.setIcon(S));const w=new o.Polyline({strokeColor:f,strokeWeight:2,isOutline:!0,outlineColor:f});w.setMap(e.value),w.setPath(g);const U=new o.Text({text:r+"M",style:{"font-size":"12px",color:"#fff",border:"none",backgroundColor:f}});U.setPosition(c),U.setMap(e.value),u=="top"&&U.setOffset(new o.Pixel(-40,-10))}}).catch(()=>{})};return C(async()=>{try{const{data:o}=await z.get("/api-web/open/school/queryByParamName",{params:{paramName:"attendance_range"}});a.attendance_range=o.attendance_range||1e3}catch(o){}s()}),()=>I("div",{class:T["amap-gps"]},[I(R,{position:"top"},{default:()=>[I(x,null,null)]}),I("div",{id:"gpsContainer",style:{width:"100%",height:"calc(100vh - var(--header-height))",position:"relative"}},null)])}});export{q as default};
|