mirror of
https://gitee.com/niucloud-team/niucloud-admin.git
synced 2025-12-29 09:50:16 +00:00
2 lines
3.5 KiB
JavaScript
2 lines
3.5 KiB
JavaScript
function b(e,t){e=e.replace(/=/g,"");var o=[];switch(t.constructor){case String:case Number:case Boolean:o.push(encodeURIComponent(e)+"="+encodeURIComponent(t));break;case Array:t.forEach(function(r){o=o.concat(b(e+"[]=",r))});break;case Object:Object.keys(t).forEach(function(r){var n=t[r];o=o.concat(b(e+"["+r+"]",n))})}return o}function g(e){var t=[];return e.forEach(function(o){typeof o=="string"?t.push(o):t=t.concat(g(o))}),t}function w(e,t,o){if(t===void 0&&(t={}),typeof e!="string")throw new Error('[Vue-jsonp] Type of param "url" is not string.');if(typeof t!="object"||!t)throw new Error("[Vue-jsonp] Invalid params, should be an object.");return o=typeof o=="number"?o:5e3,new Promise(function(r,n){var c=typeof t.callbackQuery=="string"?t.callbackQuery:"callback",l=typeof t.callbackName=="string"?t.callbackName:"jsonp_"+(Math.floor(1e5*Math.random())*Date.now()).toString(16);t[c]=l,delete t.callbackQuery,delete t.callbackName;var a=[];Object.keys(t).forEach(function(y){a=a.concat(b(y,t[y]))});var u=g(a).join("&"),s=function(){p(),clearTimeout(h),n({status:400,statusText:"Bad Request"})},p=function(){i.removeEventListener("error",s)},f=function(){document.body.removeChild(i),delete window[l]},h=null;o>-1&&(h=setTimeout(function(){p(),f(),n({statusText:"Request Timeout",status:408})},o)),window[l]=function(y){clearTimeout(h),p(),f(),r(y)};var i=document.createElement("script");i.addEventListener("error",s),i.src=e+(/\?/.test(e)?"&":"?")+u,document.body.appendChild(i)})}const d={},M=(e,t)=>{const o=window.TMap,r=o.LatLng;t.radius=t.radius??1e3,t.center=t.center??{lat:e.getCenter().lat,lng:e.getCenter().lng};const n=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],c=new o.MultiCircle({map:e,styles:{circle:new o.CircleStyle({color:`rgba(${n.toString()}, .4)`,showBorder:!0,borderColor:`rgb(${n.toString()})`,borderWidth:2})},geometries:[{styleId:"circle",center:new r(t.center.lat,t.center.lng),radius:t.radius,id:t.key}]});d[t.key]={graphical:c};const l=new o.tools.GeometryEditor({map:e,overlayList:[{overlay:c,id:t.key}],actionMode:o.tools.constants.EDITOR_ACTION.INTERACT,activeOverlayId:t.key,selectable:!0});l.on("adjust_complete",a=>{t.center=a.center,t.radius=a.radius}),d[t.key]={graphical:c,editor:l}},k=(e,t)=>{const o=window.TMap,r=o.LatLng,{lat:n,lng:c}=e.getCenter();t.paths=t.paths??[{lat:n+.01,lng:c+.01},{lat:n-.01,lng:c+.01},{lat:n-.01,lng:c-.01},{lat:n+.01,lng:c-.01}];const l=[Math.floor(Math.random()*255),Math.floor(Math.random()*255),Math.floor(Math.random()*255)],a=new o.MultiPolygon({map:e,styles:{polygon:new o.PolygonStyle({color:`rgba(${l.toString()}, .4)`,showBorder:!0,borderColor:`rgb(${l.toString()})`,borderWidth:2})},geometries:[{id:t.key,styleId:"polygon",paths:t.paths.map(s=>new r(s.lat,s.lng))}]}),u=new o.tools.GeometryEditor({map:e,overlayList:[{overlay:a,id:t.key}],actionMode:o.tools.constants.EDITOR_ACTION.INTERACT,activeOverlayId:t.key,selectable:!0});u.on("adjust_complete",s=>{t.paths=s.paths}),d[t.key]={graphical:a,editor:u}},v=e=>{d[e].graphical.remove(e),d[e].editor.delete()},T=e=>{d[e].editor.select([e])},m=e=>{const t=window.TMap;return t.LatLng,new t.MultiMarker({map:e,geometries:[{id:"center",position:e.getCenter()}]})},C=e=>w(`https://apis.map.qq.com/ws/geocoder/v1/?key=${e.mapKey}&location=${e.lat},${e.lng}&output=jsonp&callback=callback`),L=e=>w(`https://apis.map.qq.com/ws/geocoder/v1/?key=${e.mapKey}&address=${e.address}&output=jsonp&callback=callback`);export{L as a,M as b,m as c,k as d,v as e,C as l,T as s};
|