import{d as Q,b as L,r as d,s as E,p as N,c as i,e as u,k as M,i as r,g as V,h as c,u as t,f as b,w as W,aY as X,q as T,A as w,j as $,m as D,t as ee,F as oe,aZ as te,y as ae,_ as le}from"./index.0308b213.js";import{P as ne,E as se,s as ie,h as ce}from"./loading.c9286a4b.js";import{g as ue}from"./setting.644fa418.js";const re={key:0,class:"search-wrap"},pe={key:1,class:"map-wrap",style:{width:"100%",height:"400px"}},ge={key:2,class:"map-wrap",style:{width:"100%",height:"400px"}},de={class:"dialog-footer"},me=D("\u53D6\u6D88"),_e=D("\u786E\u8BA4"),ye=Q({props:{modelValue:{type:Boolean,default:!1},lat:{default:0},lng:{default:0}},emits:["update:modelValue","onClose","update:lat","update:lng"],setup(J,{emit:k}){const m=J,a=L({key:"",securityJsCode:"",google_key:"",map_type:1});let _=d("");const F=L({list:[]});let p=d(!1),x=d(!1),P=d({city:"\u5168\u56FD",citylimit:!1});const I=e=>{localStorage.getItem("initAMapConfig"),ue().then(o=>{a.key=o.key,a.securityJsCode=o.securityJsCode,a.google_key=o.google_key,a.map_type=o.map_type,localStorage.setItem("initAMapConfig",JSON.stringify(a)),e&&O()})},O=()=>{a.map_type==1&&te({securityJsCode:a.securityJsCode,key:a.key,version:"2.0",plugin:["AMap.Scale","AMap.OverView","AMap.ToolBar","AMap.MapType"],v:"1.4.4"}),p.value=!0,ae(()=>{x.value=!0})};let y=d(0),f=d(0);const A=E(()=>({position:[Number(f.value),Number(y.value)],label:{content:"\u8BF7\u60A8\u79FB\u52A8\u6B64\u6807\u8BB0\uFF0C\u9009\u62E9\u60A8\u7684\u5750\u6807",offset:[-90,-30]}})),h=E(()=>A.value.position);N(()=>m.modelValue,e=>{e&&(I(e),f.value=Number(m.lng)||116.397471,y.value=Number(m.lat)||39.909098)}),N(()=>[m.lng,m.lat],e=>{f.value=e[0],y.value=e[1]});const B=()=>{x.value=!1,p.value=!1,k("update:modelValue",!1),k("onClose")},z=()=>{k("update:lng",f.value),k("update:lat",y.value),B()},G=e=>{v(e.position[0],e.position[1])},R=e=>{v(e.lnglat.lng,e.lnglat.lat)},U=e=>{console.log(e),v(e.poi.location.lng,e.poi.location.lat)},v=(e,o)=>{y.value=o,f.value=e},j=e=>{const o=e.latLng,l=o.lat(),n=o.lng();v(n,l)},q=()=>{let e=_.value;if(!!e){ie({text:"\u52A0\u8F7D\u4E2D..."});var o=new google.maps.places.AutocompleteSessionToken;console.log(o);var l=new google.maps.places.AutocompleteService;l.getPlacePredictions({input:e,sessionToken:o},(n,g)=>{F.list=n,console.log(n),console.log(g),ce()})}},K=e=>{console.log(e);var o=new google.maps.Geocoder;o.geocode({placeId:e.place_id},function(l,n){if(n=="OK"){console.log(l);let g=l[0].geometry.location.lat(),C=l[0].geometry.location.lng();console.log(g,C),v(C,g)}})};return(e,o)=>{const l=i("el-tag"),n=i("el-amap-control-tool-bar"),g=i("el-amap-control-geolocation"),C=i("el-amap-search-box"),Y=i("el-amap-marker"),Z=i("el-amap"),S=i("el-button"),H=i("el-dialog");return u(),M(H,{modelValue:t(p),"onUpdate:modelValue":o[1]||(o[1]=s=>T(p)?p.value=s:p=s),title:"\u8BF7\u9009\u62E9\u5730\u70B9",width:"60%",draggable:"","destroy-on-close":!0,onClose:B},{footer:r(()=>[V("span",de,[c(S,{onClick:B},{default:r(()=>[me]),_:1}),c(S,{type:"primary",onClick:z},{default:r(()=>[_e]),_:1})])]),default:r(()=>[t(a).map_type==2?(u(),b("div",re,[W(V("input",{placeholder:"\u8BF7\u8F93\u5165\u5730\u5740\u540D\u79F0",type:"text",id:"position-search-input",class:"position-search-input",onBlur:q,"onUpdate:modelValue":o[0]||(o[0]=s=>T(_)?_.value=s:_=s)},null,544),[[X,t(_)]])])):w("",!0),V("div",null,[(u(!0),b(oe,null,$(t(F).list,(s,fe)=>(u(),M(l,{type:"primary",style:{"margin-right":"10px","margin-top":"10px"},onClick:he=>K(s)},{default:r(()=>[D(ee(s.description),1)]),_:2},1032,["onClick"]))),256))]),t(a).map_type==1?(u(),b("div",pe,[t(x)?(u(),M(Z,{key:0,ref:"amap",vid:"amap-vue-choose",center:t(h),zoom:15},{default:r(()=>[c(n),c(g,{visible:!0,position:"LB","show-circle":!0,"show-marker":!0,"pan-to-location":!0,"zoom-to-accuracy":!0,"get-city-when-fail":!0,onComplete:G}),c(C,{class:"search-box","search-option":t(P),onSelect:U},null,8,["search-option"]),c(Y,{position:t(A).position,label:t(A).label,draggable:!0,onDragend:R},null,8,["position","label"])]),_:1},8,["center"])):w("",!0)])):w("",!0),t(a).map_type==2?(u(),b("div",ge,[c(t(se),{ref:"googlemap","api-key":t(a).google_key,style:{width:"100%",height:"380px"},center:{lat:t(h)[1],lng:t(h)[0]},zoom:15},{default:r(()=>[c(t(ne),{options:{position:{lat:t(h)[1],lng:t(h)[0]},draggable:!0,clickable:!0},onDragend:j},null,8,["options"])]),_:1},8,["api-key","center"])])):w("",!0)]),_:1},8,["modelValue"])}}});const be=le(ye,[["__scopeId","data-v-e81ef48e"]]);export{be as C};
