@amap-aca98dec.js 5.4 KB

1
  1. var m=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function y(d){return d&&d.__esModule&&Object.prototype.hasOwnProperty.call(d,"default")?d.default:d}function P(d){if(d.__esModule)return d;var v=d.default;if(typeof v=="function"){var f=function c(){return this instanceof c?Reflect.construct(v,arguments,this.constructor):v.apply(this,arguments)};f.prototype=v.prototype}else f={};return Object.defineProperty(f,"__esModule",{value:!0}),Object.keys(d).forEach(function(c){var w=Object.getOwnPropertyDescriptor(d,c);Object.defineProperty(f,c,w.get?w:{enumerable:!0,get:function(){return d[c]}})}),f}var b={exports:{}};(function(d,v){(function(f,c){d.exports=c()})(m,function(){function f(e){var r=[];return e.AMapUI&&r.push(c(e.AMapUI)),e.Loca&&r.push(w(e.Loca)),Promise.all(r)}function c(e){return new Promise(function(r,o){var a=[];if(e.plugins)for(var i=0;i<e.plugins.length;i+=1)u.AMapUI.plugins.indexOf(e.plugins[i])==-1&&a.push(e.plugins[i]);if(p.AMapUI===n.failed)o("前次请求 AMapUI 失败");else if(p.AMapUI===n.notload){p.AMapUI=n.loading,u.AMapUI.version=e.version||u.AMapUI.version,i=u.AMapUI.version;var l=document.body||document.head,s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/ui/"+i+"/main.js",s.onerror=function(t){p.AMapUI=n.failed,o("请求 AMapUI 失败")},s.onload=function(){if(p.AMapUI=n.loaded,a.length)window.AMapUI.loadUI(a,function(){for(var t=0,M=a.length;t<M;t++){var g=a[t].split("/").slice(-1)[0];window.AMapUI[g]=arguments[t]}for(r();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()});else for(r();A.AMapUI.length;)A.AMapUI.splice(0,1)[0]()},l.appendChild(s)}else p.AMapUI===n.loaded?e.version&&e.version!==u.AMapUI.version?o("不允许多个版本 AMapUI 混用"):a.length?window.AMapUI.loadUI(a,function(){for(var t=0,M=a.length;t<M;t++){var g=a[t].split("/").slice(-1)[0];window.AMapUI[g]=arguments[t]}r()}):r():e.version&&e.version!==u.AMapUI.version?o("不允许多个版本 AMapUI 混用"):A.AMapUI.push(function(t){t?o(t):a.length?window.AMapUI.loadUI(a,function(){for(var M=0,g=a.length;M<g;M++){var U=a[M].split("/").slice(-1)[0];window.AMapUI[U]=arguments[M]}r()}):r()})})}function w(e){return new Promise(function(r,o){if(p.Loca===n.failed)o("前次请求 Loca 失败");else if(p.Loca===n.notload){p.Loca=n.loading,u.Loca.version=e.version||u.Loca.version;var a=u.Loca.version,i=u.AMap.version.startsWith("2"),l=a.startsWith("2");if(i&&!l||!i&&l)o("JSAPI 与 Loca 版本不对应!!");else{i=u.key,l=document.body||document.head;var s=document.createElement("script");s.type="text/javascript",s.src="https://webapi.amap.com/loca?v="+a+"&key="+i,s.onerror=function(t){p.Loca=n.failed,o("请求 AMapUI 失败")},s.onload=function(){for(p.Loca=n.loaded,r();A.Loca.length;)A.Loca.splice(0,1)[0]()},l.appendChild(s)}}else p.Loca===n.loaded?e.version&&e.version!==u.Loca.version?o("不允许多个版本 Loca 混用"):r():e.version&&e.version!==u.Loca.version?o("不允许多个版本 Loca 混用"):A.Loca.push(function(t){t?o(t):o()})})}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var n;(function(e){e.notload="notload",e.loading="loading",e.loaded="loaded",e.failed="failed"})(n||(n={}));var u={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},p={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},A={AMap:[],AMapUI:[],Loca:[]},I=[],h=function(e){typeof e=="function"&&(p.AMap===n.loaded?e(window.AMap):I.push(e))};return{load:function(e){return new Promise(function(r,o){if(p.AMap==n.failed)o("");else if(p.AMap==n.notload){var a=e.key,i=e.version,l=e.plugins;a?(window.AMap&&location.host!=="lbs.amap.com"&&o("禁止多种API加载方式混用"),u.key=a,u.AMap.version=i||u.AMap.version,u.AMap.plugins=l||u.AMap.plugins,p.AMap=n.loading,i=document.body||document.head,window.___onAPILoaded=function(t){if(delete window.___onAPILoaded,t)p.AMap=n.failed,o(t);else for(p.AMap=n.loaded,f(e).then(function(){r(window.AMap)}).catch(o);I.length;)I.splice(0,1)[0]()},l=document.createElement("script"),l.type="text/javascript",l.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+u.AMap.version+"&key="+a+"&plugin="+u.AMap.plugins.join(","),l.onerror=function(t){p.AMap=n.failed,o(t)},i.appendChild(l)):o("请填写key")}else if(p.AMap==n.loaded)if(e.key&&e.key!==u.key)o("多个不一致的 key");else if(e.version&&e.version!==u.AMap.version)o("不允许多个版本 JSAPI 混用");else{if(a=[],e.plugins)for(i=0;i<e.plugins.length;i+=1)u.AMap.plugins.indexOf(e.plugins[i])==-1&&a.push(e.plugins[i]);a.length?window.AMap.plugin(a,function(){f(e).then(function(){r(window.AMap)}).catch(o)}):f(e).then(function(){r(window.AMap)}).catch(o)}else if(e.key&&e.key!==u.key)o("多个不一致的 key");else if(e.version&&e.version!==u.AMap.version)o("不允许多个版本 JSAPI 混用");else{var s=[];if(e.plugins)for(i=0;i<e.plugins.length;i+=1)u.AMap.plugins.indexOf(e.plugins[i])==-1&&s.push(e.plugins[i]);h(function(){s.length?window.AMap.plugin(s,function(){f(e).then(function(){r(window.AMap)}).catch(o)}):f(e).then(function(){r(window.AMap)}).catch(o)})}})},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,u={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},p={AMap:n.notload,AMapUI:n.notload,Loca:n.notload},A={AMap:[],AMapUI:[],Loca:[]}}}})})(b);var L=b.exports;const _=y(L);export{_ as A,P as a,m as c,y as g};