UNPKG

ooomap-combine-amap

Version:

ooomap结合高德地图实现室内外一体化

2 lines (1 loc) 8.83 kB
!function(e,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((e="undefined"!=typeof globalThis?globalThis:e||self).om=(e="undefined"!=typeof globalThis?globalThis:e||self).om||{})}(this,(function(e){"use strict";"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self&&self;var n=function(e,n){return function(e,n){e.exports=function(){function e(e){var a=[];return e.AMapUI&&a.push(n(e.AMapUI)),e.Loca&&a.push(o(e.Loca)),Promise.all(a)}function n(e){return new Promise((function(n,o){var i=[];if(e.plugins)for(var s=0;s<e.plugins.length;s+=1)-1==t.AMapUI.plugins.indexOf(e.plugins[s])&&i.push(e.plugins[s]);if(r.AMapUI===a.failed)o("前次请求 AMapUI 失败");else if(r.AMapUI===a.notload){r.AMapUI=a.loading,t.AMapUI.version=e.version||t.AMapUI.version,s=t.AMapUI.version;var p=document.body||document.head,c=document.createElement("script");c.type="text/javascript",c.src="https://webapi.amap.com/ui/"+s+"/main.js",c.onerror=function(e){r.AMapUI=a.failed,o("请求 AMapUI 失败")},c.onload=function(){if(r.AMapUI=a.loaded,i.length)window.AMapUI.loadUI(i,(function(){for(var e=arguments,o=0,a=i.length;o<a;o++){var t=i[o].split("/").slice(-1)[0];window.AMapUI[t]=e[o]}for(n();l.AMapUI.length;)l.AMapUI.splice(0,1)[0]()}));else for(n();l.AMapUI.length;)l.AMapUI.splice(0,1)[0]()},p.appendChild(c)}else r.AMapUI===a.loaded?e.version&&e.version!==t.AMapUI.version?o("不允许多个版本 AMapUI 混用"):i.length?window.AMapUI.loadUI(i,(function(){for(var e=arguments,o=0,a=i.length;o<a;o++){var t=i[o].split("/").slice(-1)[0];window.AMapUI[t]=e[o]}n()})):n():e.version&&e.version!==t.AMapUI.version?o("不允许多个版本 AMapUI 混用"):l.AMapUI.push((function(e){e?o(e):i.length?window.AMapUI.loadUI(i,(function(){for(var e=arguments,o=0,a=i.length;o<a;o++){var t=i[o].split("/").slice(-1)[0];window.AMapUI[t]=e[o]}n()})):n()}))}))}function o(e){return new Promise((function(n,o){if(r.Loca===a.failed)o("前次请求 Loca 失败");else if(r.Loca===a.notload){r.Loca=a.loading,t.Loca.version=e.version||t.Loca.version;var i=t.Loca.version,s=t.AMap.version.startsWith("2"),p=i.startsWith("2");if(s&&!p||!s&&p)o("JSAPI 与 Loca 版本不对应!!");else{s=t.key,p=document.body||document.head;var c=document.createElement("script");c.type="text/javascript",c.src="https://webapi.amap.com/loca?v="+i+"&key="+s,c.onerror=function(e){r.Loca=a.failed,o("请求 AMapUI 失败")},c.onload=function(){for(r.Loca=a.loaded,n();l.Loca.length;)l.Loca.splice(0,1)[0]()},p.appendChild(c)}}else r.Loca===a.loaded?e.version&&e.version!==t.Loca.version?o("不允许多个版本 Loca 混用"):n():e.version&&e.version!==t.Loca.version?o("不允许多个版本 Loca 混用"):l.Loca.push((function(e){e?o(e):o()}))}))}if(!window)throw Error("AMap JSAPI can only be used in Browser.");var a,i;(i=a||(a={})).notload="notload",i.loading="loading",i.loaded="loaded",i.failed="failed";var t={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},r={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},l={AMap:[],AMapUI:[],Loca:[]},s=[];return{load:function(n){return new Promise((function(o,i){if(r.AMap==a.failed)i("");else if(r.AMap==a.notload){var l=n.key,p=n.version,c=n.plugins;l?(window.AMap&&"lbs.amap.com"!==location.host&&i("禁止多种API加载方式混用"),t.key=l,t.AMap.version=p||t.AMap.version,t.AMap.plugins=c||t.AMap.plugins,r.AMap=a.loading,p=document.body||document.head,window.___onAPILoaded=function(t){if(delete window.___onAPILoaded,t)r.AMap=a.failed,i(t);else for(r.AMap=a.loaded,e(n).then((function(){o(window.AMap)})).catch(i);s.length;)s.splice(0,1)[0]()},(c=document.createElement("script")).type="text/javascript",c.src="https://webapi.amap.com/maps?callback=___onAPILoaded&v="+t.AMap.version+"&key="+l+"&plugin="+t.AMap.plugins.join(","),c.onerror=function(e){r.AMap=a.failed,i(e)},p.appendChild(c)):i("请填写key")}else if(r.AMap==a.loaded)if(n.key&&n.key!==t.key)i("多个不一致的 key");else if(n.version&&n.version!==t.AMap.version)i("不允许多个版本 JSAPI 混用");else{if(l=[],n.plugins)for(p=0;p<n.plugins.length;p+=1)-1==t.AMap.plugins.indexOf(n.plugins[p])&&l.push(n.plugins[p]);l.length?window.AMap.plugin(l,(function(){e(n).then((function(){o(window.AMap)})).catch(i)})):e(n).then((function(){o(window.AMap)})).catch(i)}else if(n.key&&n.key!==t.key)i("多个不一致的 key");else if(n.version&&n.version!==t.AMap.version)i("不允许多个版本 JSAPI 混用");else{var d=[];if(n.plugins)for(p=0;p<n.plugins.length;p+=1)-1==t.AMap.plugins.indexOf(n.plugins[p])&&d.push(n.plugins[p]);!function(e){r.AMap===a.loaded?e(window.AMap):s.push(e)}((function(){d.length?window.AMap.plugin(d,(function(){e(n).then((function(){o(window.AMap)})).catch(i)})):e(n).then((function(){o(window.AMap)})).catch(i)}))}}))},reset:function(){delete window.AMap,delete window.AMapUI,delete window.Loca,t={key:"",AMap:{version:"1.4.15",plugins:[]},AMapUI:{version:"1.1",plugins:[]},Loca:{version:"1.3.2"}},r={AMap:a.notload,AMapUI:a.notload,Loca:a.notload},l={AMap:[],AMapUI:[],Loca:[]}}}}()}(n={exports:{}}),n.exports}(),o=function(){this.callbacks=[],this.alldoneArr=[],this.type="OMPromise",this.__done=!1,this.id=Math.random().toString().slice(2)};o.prototype.delay=function(e){var n=new this.constructor;return setTimeout((function(){n.resolve()}),e),n},o.prototype.addAlldone=function(e){this.alldoneArr.push(e)},o.prototype.alldone=function(e){this.alldoneArr.forEach((function(n){n(e)}))},o.prototype.destroy=function(){this.callbacks.length=this.alldoneArr.length=0},o.prototype.then=function(e){return this.callbacks.push(e),this},o.prototype._hasIndex=function(e){return void 0!==this.__index&&(e.__index=this.__index),e},o.prototype.resolve=function(e){var n=this,o=null,a=!1;setTimeout((function(){var i=n._hasIndex(o||e);if(!n.callbacks.length)return n.alldone(i),n.destroy(),void(n.__done=!0);for(var t=0;t<n.callbacks.length;t++){var r=n.callbacks[t](o||e);if(r instanceof n.constructor){for(a=!0,t++;t<n.callbacks.length;t++)r.then(n.callbacks[t]);n.alldoneArr.length&&(r.alldoneArr=n.alldoneArr),o=null}else o=r}a||(i=n._hasIndex(o||e),n.alldone(i),n.destroy(),n.__done=!0)}),0)},o.empty=function(e){var n=new o;return setTimeout((function(){n.resolve(e)}),0),n},o.delay=function(e){var n=new o;return setTimeout((function(){n.resolve()}),e),n},o.all=function(e,n){e=e.filter((function(e){return!e.__done}));var prom=new o,a=0,i=[];function t(o){a++,i.push(o),a===e.length&&(n&&(i.sort((function(e,n){return void 0!==e.__index&&void 0!==n.__index?e.__index-n.__index:0})),i.forEach((function(e){return delete e.__index}))),prom.resolve(i))}return e.forEach((function(e){e.addAlldone(t)})),prom};var a=!1;e.createOAMap=function(e,i){var prom=new o;if((e=Object.assign({maxPolarAngle:90},e)).container&&e.appID&&e.verifyUrl)return i=Object.assign({viewMode:"3D",pitch:42,zoom:15,zooms:[12,22],expandZoomRange:!0,animateEnable:!1,features:["bg","road","building","point"]},i),function e(a,i,prom){if(prom=prom||new o,!window.AMap)return n.load({key:"e63aea46d6996e90fceb6d53d7aee03c",version:"2.0",plugins:[]}).then((function(){return e(a,i,prom)})),prom;var t=new AMap.Map(a,i);return prom.resolve(t),prom}(e.container,i).then((function(n){n.on("click",(function(e){})),function(e,n,i){n=n||[0,0];var t=e.customCoords;t.lngLatsToCoords([n]);var r,prom=new o,l=new AMap.GLCustomLayer({zIndex:1e3,zooms:[15,22],init:function(n){(r=new om.Map(Object.assign({context:n,container:container,appID:"87ae6a00e5ca4e33dd7e858a66b73475",verifyUrl:"https://www.ooomap.com/ooomap-verify/check/50689bb01e0ac2a9d93bb18f1e1260f8",useAOEffect:!1,viewFloors:1},i))).view.backgroundColor="#ffffff",r.on("ready",(function(){a=!0})),r.on("picked",(function(e){e&&e.node&&("SpriteMarkerNode"===e.node.type?e.node.flash():"OMBlock"===e.node.type&&e.node.flashHeight())})),r.on("sceneLoaded",(function(e){r.view.backgroundColor="#ffffff"})),r.on("floorLoaded",(function(e){r.view.maxPolarAngle=90})),r.on("pre-render",(function(){var e;if(a){var n=t.getCameraParams(),o=n.near,i=n.far,l=n.fov,s=n.up,p=n.lookAt,c=n.position,d=r.view.camera;d.near=o,d.far=i,d.fov=l,r.view.controls.object.position.fromArray(c),(e=r.view.controls.object.up).set.apply(e,s),r.view.controls.target.fromArray(p),r.view.controls.object.updateProjectionMatrix(),r.view.controls.update()}}));var o=1e3/r.frameRate,s=0;!function n(){++s>o&&(s=0,e.render()),requestAnimationFrame(n)}(),prom.resolve({map:r,gllayer:l})},render:function(){r&&r._pause||r.update()}});return e.add(l),prom}(n,i.center,e).then((function(e){var o=e.map,a=e.gllayer;prom.resolve({map:o,amap:n,gllayer:a})}))})),prom},Object.defineProperty(e,"__esModule",{value:!0})}));