ol-cesium
Version:
OpenLayers Cesium integration library
2 lines • 4.78 kB
JavaScript
!function(e){function t(t){for(var n,s,c=t[0],a=t[1],l=t[2],d=0,u=[];d<c.length;d++)s=c[d],i[s]&&u.push(i[s][0]),i[s]=0;for(n in a)Object.prototype.hasOwnProperty.call(a,n)&&(e[n]=a[n]);for(p&&p(t);u.length;)u.shift()();return r.push.apply(r,l||[]),o()}function o(){for(var e,t=0;t<r.length;t++){for(var o=r[t],n=!0,c=1;c<o.length;c++){var a=o[c];0!==i[a]&&(n=!1)}n&&(r.splice(t--,1),e=s(s.s=o[0]))}return e}var n={},i={13:0},r=[];function s(t){if(n[t])return n[t].exports;var o=n[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,s),o.l=!0,o.exports}s.m=e,s.c=n,s.d=function(e,t,o){s.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:o})},s.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},s.t=function(e,t){if(1&t&&(e=s(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var n in e)s.d(o,n,function(t){return e[t]}.bind(null,n));return o},s.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return s.d(t,"a",t),t},s.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},s.p="";var c=window.webpackJsonp=window.webpackJsonp||[],a=c.push.bind(c);c.push=t,c=c.slice();for(var l=0;l<c.length;l++)t(c[l]);var p=a;r.push([177,0]),o()}({177:function(e,t,o){e.exports=o(178)},178:function(e,t,o){"use strict";o.r(t);var n=o(27),i=o(26),r=o(25),s=o(17),c=o(5),a=o(21),l=o(70),p=o(114),d=o(53);const u=new r.b;Cesium.Ion.defaultAccessToken="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiI0MzAyNzUyYi0zY2QxLTQxZDItODRkOS1hNTA3MDU3ZTBiMDUiLCJpZCI6MjU0MSwiaWF0IjoxNTMzNjI1MTYwfQ.oHn1SUWJa12esu7XUUtEoc1BbEbuZpRocLetw6M6_AA";const h=new i.a({layers:[new s.a({source:u})],controls:Object(l.a)({attributionOptions:{collapsible:!1}}),target:"map",view:new a.a({center:Object(c.l)([-112.2,36.06],"EPSG:4326","EPSG:3857"),zoom:11})}),y=new n.a({map:h,target:"map3d"}),b=y.getCesiumScene();b.terrainProvider=Cesium.createWorldTerrain();new class{constructor(e,t,o){this.ol2d=e,this.ol3d=t,this.scene=o,this.staticOverlay=new p.a({element:document.getElementById("popup")}),this.staticBootstrapPopup=new p.a({element:document.getElementById("popup-bootstrap")}),this.ol2d.addOverlay(this.staticOverlay),this.ol2d.addOverlay(this.staticBootstrapPopup),this.options={boostrap:!1,add:!0},this.ol2d.on("click",this.onClickHandlerOL.bind(this)),new Cesium.ScreenSpaceEventHandler(o.canvas).setInputAction(this.onClickHandlerCS.bind(this),Cesium.ScreenSpaceEventType.LEFT_CLICK),document.getElementById("click-action-form").onchange=function(e){const t=$('input[name="click-action"]:checked').val();this.options.add="add"===t}.bind(this),document.getElementById("overlay-type-form").onchange=function(e){const t=$('input[name="overlay-type"]:checked').val();this.options.boostrap="popover"===t}.bind(this)}onClickHandlerOL(e){const t=e.coordinate,o=Object(d.e)(Object(c.l)(t,"EPSG:3857","EPSG:4326")),n=this.getOverlay();n.setPosition(t),this.setOverlayContent(n,o)}onClickHandlerCS(e){if(0===e.position.x&&0===e.position.y)return;const t=this.scene.camera.getPickRay(e.position),o=this.scene.globe.pick(t,b);if(!o)return;const n=b.globe.ellipsoid.cartesianToCartographic(o);let i=[Cesium.Math.toDegrees(n.longitude),Cesium.Math.toDegrees(n.latitude)];const r=b.globe.getHeight(n);r&&(i=i.concat([r]));const s=Object(c.l)(i,Object(c.h)("EPSG:4326"),"EPSG:3857"),a=Object(d.e)(i),l=this.getOverlay();l.setPosition(s),this.setOverlayContent(l,a)}getOverlay(){return this.options.add?this.addOverlay():this.options.boostrap?this.staticBootstrapPopup:this.staticOverlay}setOverlayContent(e,t){const o=e.getElement();if(this.options.boostrap){const n=document.createElement("div");n.onclick=this.onCloseClick.bind(this,e,this.options.add),n.innerHTML=`<p>The location you clicked was:</p><code>${t}</code>`,$(o).popover("destroy"),$(o).popover({placement:"top",animation:!1,html:!0,content:n}),$(o).popover("show")}else o.childNodes.forEach(o=>{"popup-content"===o.id?o.innerHTML=`<p>The location you clicked was:</p><code>${t}</code>`:"popup-closer"===o.id&&(o.onclick=this.onCloseClick.bind(this,e,this.options.add))})}onCloseClick(e,t){t?this.ol2d.removeOverlay(e):e.setPosition(void 0)}addOverlay(){let e;e=this.options.boostrap?document.getElementById("popup-bootstrap").cloneNode(!0):document.getElementById("popup").cloneNode(!0);const t=new p.a({element:e});return this.ol2d.addOverlay(t),t}}(h,y,b),document.getElementById("enable").addEventListener("click",()=>y.setEnabled(!y.getEnabled())),t.default={}}});
//# sourceMappingURL=overlay.336dc4a9672887ee469d.js.map