@here/harp-examples
Version:
harp.gl Examples
1 lines • 5.69 kB
JavaScript
(()=>{"use strict";var e={2334:(e,t,o)=>{t.F=void 0;const n=o(2194),r=o(8957),a=o(4908),i=o(5636),l=o(3074),s=o(2998),d=o(4565);!function(e){const t=document.createElement("div");let o,c,u,p;function h(e,t,o=!0){if(u&&(null==t||t.remove(u)),p&&(null==t||t.remove(p)),o){const o=e.getGeoBoundingBox(),a=[];[new r.GeoCoordinates(null==o?void 0:o.south,null==o?void 0:o.west,70),new r.GeoCoordinates(null==o?void 0:o.south,null==o?void 0:o.east,70),new r.GeoCoordinates(null==o?void 0:o.north,null==o?void 0:o.east,70),new r.GeoCoordinates(null==o?void 0:o.north,null==o?void 0:o.west,70),new r.GeoCoordinates(null==o?void 0:o.south,null==o?void 0:o.west,70)].forEach((e=>{e&&a.push([e.longitude,e.latitude,e.altitude])}));const i=e.getCentroid();u=new n.MapViewMultiPointFeature([[i.longitude,i.latitude,70]].concat(a),{name:"bbox"}),null==t||t.add(u),p=new n.MapViewPolygonFeature([a],{name:"bbox"}),null==t||t.add(p)}}t.innerHTML='\n <br /> Press "space" to generate and draw a bounds polygon of the current view\n <br /> Press "h" to look at the last created Polygon\'s BoundingBox\n <br /> Press "g" to look at the last created Polygon\n <br /> Press "b" to show the boundingbox of the Polygon\n <br /> Press "p" to toggle the projection\n <br /> Press "w" to toggle tile wrapping in planar projection',t.style.position="absolute",t.style.cssFloat="right",t.style.top="10px",t.style.right="10px",t.style.textAlign="left",t.style.textShadow="0px 0px 2px gray",document.body.appendChild(t),e.mapView=function(t){const u=document.getElementById("mapCanvas"),p=new r.GeoCoordinates(52.5186234,13.373993),g=new l.MapView({canvas:u,projection:r.mercatorProjection,tileWrappingEnabled:!1,theme:{extends:"resources/berlin_tilezen_night_reduced.json",styles:{geojson:[{when:["all",["==",["geometry-type"],"Polygon"],["==",["get","name"],"bounds"]],technique:"fill",renderOrder:10003,attr:{color:["get","color"],opacity:.2,lineWidth:1,lineColor:"#ff0000",enabled:!0}},{when:["all",["==",["geometry-type"],"Polygon"],["==",["get","name"],"bbox"]],technique:"solid-line",renderOrder:10005,attr:{color:"#0ff",lineWidth:"5px"}},{when:["all",["==",["geometry-type"],"Point"],["==",["get","name"],"bbox"]],technique:"circles",renderOrder:10006,attr:{color:"#00f",size:20}},{when:"$geometryType == 'point'",technique:"circles",renderOrder:10004,attr:{color:"#f0f",size:10}}]}},target:p,zoomLevel:8,tilt:45,heading:-80});g.renderLabels=!1,l.CopyrightElementHandler.install("copyrightNotice",g);const w=new i.MapControls(g);w.maxTiltAngle=180;const b=new i.MapControlsUI(w,{zoomLevel:"input"});u.parentElement.appendChild(b.domElement),g.resize(window.innerWidth,window.innerHeight),window.addEventListener("resize",(()=>{g.resize(window.innerWidth,window.innerHeight)})),function(e){const t=new s.VectorTileDataSource({baseUrl:"https://vector.hereapi.com/v2/vectortiles/base/mc",authenticationCode:d.apikey});e.addDataSource(t)}(g);const m=function(e,t){const o=new n.FeaturesDataSource({name:"featureDataSource",styleSetName:"geojson",features:[],gatherFeatureAttributes:!0});return e.addDataSource(o),o}(g),f=new l.BoundsGenerator(g.camera,g.projection,g.tileWrappingEnabled);let y,v=!1;return window.addEventListener("keyup",(t=>{switch(t.key){case" ":y=f.generate(),void 0!==y&&(function(e,t){const r=e.coordinates;r&&r.length>0&&r.push(r[0].clone());const i=[],l=[];i.push(l),r.forEach((e=>{null!==e&&l.push(a.geoCoordLikeToGeoPointLike(e))})),o&&(null==t||t.remove(o)),o=new n.MapViewPolygonFeature(i,{name:"bounds",height:1e4,color:"#ffff00"}),null==t||t.add(o),c&&(null==t||t.remove(c)),c=new n.MapViewMultiPointFeature(l,{name:"cornerpoints"}),null==t||t.add(c)}(y,m),h(y,m,v));break;case"h":g.lookAt({bounds:null==y?void 0:y.getGeoBoundingBox()});break;case"g":g.lookAt({bounds:y});break;case"p":f.projection=g.projection=g.projection===r.mercatorProjection?r.sphereProjection:r.mercatorProjection;break;case"b":y&&(v=!v,h(y,m,v));break;case"l":console.log("target: ",g.target," tilt: ",g.tilt," heading: ",g.heading," zoom: ",g.zoomLevel," canvassize: ",g.canvas.height,g.canvas.width,"near: ",g.camera.near,"far: ",g.camera.far);break;case"w":e.mapView.tileWrappingEnabled=!e.mapView.tileWrappingEnabled,f.tileWrappingEnabled=e.mapView.tileWrappingEnabled,e.mapView.update()}})),g}()}(t.F||(t.F={}))},4428:e=>{e.exports=THREE}},t={};function o(n){if(t[n])return t[n].exports;var r=t[n]={exports:{}};return e[n].call(r.exports,r,r.exports,o),r.exports}o.m=e,o.x=e=>{},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var n in t)o.o(t,n)&&!o.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(e){if("object"==typeof window)return window}}(),o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.j=796,(()=>{var e={796:0,738:0},t=[[2334,592]],n=e=>{},r=(r,a)=>{for(var i,l,[s,d,c,u]=a,p=0,h=[];p<s.length;p++)l=s[p],o.o(e,l)&&e[l]&&h.push(e[l][0]),e[l]=0;for(i in d)o.o(d,i)&&(o.m[i]=d[i]);for(c&&c(o),r&&r(a);h.length;)h.shift()();return u&&t.push.apply(t,u),n()},a=self.webpackChunk_here_harp_examples=self.webpackChunk_here_harp_examples||[];function i(){for(var n,r=0;r<t.length;r++){for(var a=t[r],i=!0,l=1;l<a.length;l++){var s=a[l];0!==e[s]&&(i=!1)}i&&(t.splice(r--,1),n=o(o.s=a[0]))}return 0===t.length&&(o.x(),o.x=e=>{}),n}a.forEach(r.bind(null,0)),a.push=r.bind(null,a.push.bind(a));var l=o.x;o.x=()=>(o.x=l||(e=>{}),(n=i)())})(),o.x()})();