UNPKG

ol-cesium

Version:

OpenLayers Cesium integration library

2 lines 6.92 kB
!function(e){function t(t){for(var i,a,u=t[0],s=t[1],c=t[2],m=0,d=[];m<u.length;m++)a=u[m],r[a]&&d.push(r[a][0]),r[a]=0;for(i in s)Object.prototype.hasOwnProperty.call(s,i)&&(e[i]=s[i]);for(l&&l(t);d.length;)d.shift()();return o.push.apply(o,c||[]),n()}function n(){for(var e,t=0;t<o.length;t++){for(var n=o[t],i=!0,u=1;u<n.length;u++){var s=n[u];0!==r[s]&&(i=!1)}i&&(o.splice(t--,1),e=a(a.s=n[0]))}return e}var i={},r={11:0},o=[];function a(t){if(i[t])return i[t].exports;var n=i[t]={i:t,l:!1,exports:{}};return e[t].call(n.exports,n,n.exports,a),n.l=!0,n.exports}a.m=e,a.c=i,a.d=function(e,t,n){a.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},a.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},a.t=function(e,t){if(1&t&&(e=a(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(a.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var i in e)a.d(n,i,function(t){return e[t]}.bind(null,i));return n},a.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return a.d(t,"a",t),t},a.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},a.p="";var u=window.webpackJsonp=window.webpackJsonp||[],s=u.push.bind(u);u.push=t,u=u.slice();for(var c=0;c<u.length;c++)t(u[c]);var l=s;o.push([174,0]),n()}({174:function(e,t,n){e.exports=n(193)},193:function(e,t,n){"use strict";n.r(t);var i=n(5),r=n(21),o=n(70),a=n(25),u=n(17),s=n(26),c=function(){function e(e){this.promise,this.url_=e}return e.prototype.load=function(){var e=this;return this.promise||(this.promise=new Promise(function(t,n){var i=document.createElement("script");i.onload=function(){return t()},i.onerror=function(){return n()},document.head.appendChild(i),i.src=e.url_})),this.promise},e}(),l=n(27),m=n(20),d=n(77);function f(e,t,n){return(f=function(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(e){return!1}}()?Reflect.construct:function(e,t,n){var i=[null];i.push.apply(i,t);var r=new(Function.bind.apply(e,i));return n&&p(r,n.prototype),r}).apply(null,arguments)}function p(e,t){return(p=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}var h=function(e){var t,n;function i(t,n){var i,r=void 0===n?{}:n,o=r.map,a=r.cameraExtentInRadians;return(i=e.call(this)||this).cesiumUrl_=t,i.map=o,i.cameraExtentInRadians=a||null,i.boundingSphere_,i.blockLimiter_=!1,i.promise_,i.ol3d,i.cesiumInitialTilt_=Object(d.b)(50),i.fogDensity=1e-4,i.fogSSEFactor=25,i.minimumZoomDistance=2,i.maximumZoomDistance=1e7,i.limitCameraToBoundingSphereRatio=function(e){return e>3e3?9:3},i}n=e,(t=i).prototype=Object.create(n.prototype),t.prototype.constructor=t,t.__proto__=n;var r=i.prototype;return r.load=function(){var e=this;if(!this.promise_){var t=new c(this.cesiumUrl_);this.promise_=t.load().then(function(){return e.onCesiumLoaded()})}return this.promise_},r.onCesiumLoaded=function(){if(this.cameraExtentInRadians){var e=f(Cesium.Rectangle,this.cameraExtentInRadians);Cesium.Camera.DEFAULT_VIEW_RECTANGLE=e,this.boundingSphere_=Cesium.BoundingSphere.fromRectangle3D(e,Cesium.Ellipsoid.WGS84,300)}this.ol3d=this.instantiateOLCesium();var t=this.ol3d.getCesiumScene();return this.configureForUsability(t),this.configureForPerformance(t),this.dispatchEvent("load"),this.ol3d},r.instantiateOLCesium=function(){var e=new l.a({map:this.map}),t=e.getCesiumScene(),n=Cesium.createWorldTerrain();return t.terrainProvider=n,e},r.configureForPerformance=function(e){var t=e.fog;t.enabled=!0,t.density=this.fogDensity,t.screenSpaceErrorFactor=this.fogSSEFactor},r.configureForUsability=function(e){var t=e.screenSpaceCameraController;t.minimumZoomDistance=this.minimumZoomDistance,t.maximumZoomDistance=this.maximumZoomDistance,e.globe.depthTestAgainstTerrain=!0,e.globe.baseColor=Cesium.Color.WHITE,e.backgroundColor=Cesium.Color.WHITE,this.boundingSphere_&&e.postRender.addEventListener(this.limitCameraToBoundingSphere.bind(this),e),this.ol3d.enableAutoRenderLoop()},r.limitCameraToBoundingSphere=function(){var e=this;if(this.boundingSphere_&&!this.blockLimiter_){var t=this.ol3d.getCesiumScene().camera,n=t.position,i=Cesium.Cartographic.fromCartesian(n),r=this.limitCameraToBoundingSphereRatio(i.height);if(Cesium.Cartesian3.distance(this.boundingSphere_.center,n)>this.boundingSphere_.radius*r){if(!0===t.flying)return;this.blockLimiter_=!0;var o=function(){return e.blockLimiter_=!1};t.flyToBoundingSphere(this.boundingSphere_,{complete:o,cancel:o})}}},r.toggle3d=function(){var e=this;return this.load().then(function(t){var n=t.getEnabled(),i=t.getCesiumScene();return n?m.a.resetToNorthZenith(e.map,i).then(function(){t.setEnabled(!1),e.dispatchEvent("toggle")}):(t.setEnabled(!0),e.dispatchEvent("toggle"),m.a.rotateAroundBottomCenter(i,e.cesiumInitialTilt_))})},r.set3dWithView=function(e,t,n,i,r){var o=this;return this.load().then(function(a){var u=a.getEnabled(),s=a.getCesiumScene().camera,c=Cesium.Cartesian3.fromDegrees(e,t,n),l={heading:Cesium.Math.toRadians(i),pitch:Cesium.Math.toRadians(r),roll:0};u||(a.setEnabled(!0),o.dispatchEvent("toggle")),s.setView({destination:c,orientation:l})})},r.is3dEnabled=function(){return!!this.ol3d&&this.ol3d.getEnabled()},r.getHeading=function(){return this.map&&this.map.getView().getRotation()||0},r.getTiltOnGlobe=function(){var e=this.ol3d.getCesiumScene();return-m.a.computeSignedTiltAngleOnGlobe(e)},r.setHeading=function(e){var t=this.ol3d.getCesiumScene(),n=m.a.pickBottomPoint(t);n&&m.a.setHeadingUsingBottomCenter(t,e,n)},r.getOl3d=function(){return this.ol3d},r.getOlView=function(){return this.map.getView()},r.getCesiumViewMatrix=function(){return this.ol3d.getCesiumScene().camera.viewMatrix},r.getCesiumScene=function(){return this.ol3d.getCesiumScene()},r.flyToRectangle=function(e,t){var n=this;void 0===t&&(t=0);var i=this.getCesiumScene().camera,r=i.getRectangleCameraCoordinates(e),o=Cesium.Cartesian3.magnitude(r)+t;return Cesium.Cartesian3.normalize(r,r),Cesium.Cartesian3.multiplyByScalar(r,o,r),new Promise(function(e,t){n.cameraExtentInRadians?i.flyTo({destination:r,complete:function(){return e()},cancel:function(){return t()},endTransform:Cesium.Matrix4.IDENTITY}):t()})},r.getCameraExtentRectangle=function(){if(this.cameraExtentInRadians)return f(Cesium.Rectangle,this.cameraExtentInRadians)},i}(n(52).a);const g=new s.a({layers:[new u.a({source:new a.b})],controls:Object(o.a)({attributionOptions:{collapsible:!1}}),target:"map",view:new r.a({center:Object(i.l)([25,20],"EPSG:4326","EPSG:3857"),zoom:3})});window.manager=new h(window.CESIUM_URL,{map:g});t.default={}}}); //# sourceMappingURL=lazy.980ae3941542d72ee5b6.js.map