@openremote/or-map 1.15.1 → 1.15.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/umd/index.bundle.js +1 -1
- package/dist/umd/index.bundle.js.map +1 -1
- package/dist/umd/index.js +1 -1
- package/dist/umd/index.js.map +1 -1
- package/dist/umd/index.orbundle.js +2 -2
- package/dist/umd/index.orbundle.js.map +1 -1
- package/lib/mapwidget.d.ts.map +1 -1
- package/lib/mapwidget.js +1 -1
- package/lib/mapwidget.js.map +1 -1
- package/package.json +7 -6
- package/stories/map.stories.ts +106 -0
package/dist/umd/index.bundle.js
CHANGED
|
@@ -71,7 +71,7 @@ ${l.shaderPreludeCode.vertexSource}`,define:l.shaderDefine},defaultProjectionDat
|
|
|
71
71
|
L ${n+r*h} ${n+r*u}
|
|
72
72
|
A ${r} ${r} 0 ${p} 0 ${n+r*c} ${n+r*d}
|
|
73
73
|
"
|
|
74
|
-
/>`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.onClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.onClick)}onClick(){var t,i,n,r;return t=this,i=void 0,n=void 0,r=function*(){if(this.lng&&this.lat){let t=yield this._map.getSource("mapPoints").getClusterExpansionZoom(this._clusterId);this._map.easeTo({center:[this.lng,this.lat],zoom:t+.99,essential:!0})}},new(n||(n=Promise))(function(a,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function l(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var i;t.done?a(t.value):((i=t.value)instanceof n?i:new n(function(t){t(i)})).then(s,l)}c((r=r.apply(t,i||[])).next())})}};e5=function(t,i,n,r){var a,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,i,n,r);else for(var l=t.length-1;l>=0;l--)(a=t[l])&&(s=(o<3?a(s):o>3?a(i,n,s):a(i,n))||s);return o>3&&s&&Object.defineProperty(i,n,s),s}([eR("or-cluster-marker")],e5);var e3=function(t,i,n,r){return new(n||(n=Promise))(function(a,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function l(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var i;t.done?a(t.value):((i=t.value)instanceof n?i:new n(function(t){t(i)})).then(s,l)}c((r=r.apply(t,i||[])).next())})};let e4=c(977),e6=c(126),e8=c(561);class e7{constructor(t,i,n,r=!1,a=!1,o=!0,s=!0,l){this._loaded=!1,this._markersJs=new Map,this._markersGl=new Map,this._geoJsonSources=[],this._geoJsonLayers=new Map,this._showGeoCodingControl=!1,this._showBoundaryBox=!1,this._useZoomControls=!0,this._showGeoJson=!0,this._clickHandlers=new Map,this._pointsMap={type:"FeatureCollection",features:[]},this._assetTypeColors={},this._cachedMarkers={},this._markersOnScreen={},this._assetsOnScreen={},this._type=t,this._styleParent=i,this._mapContainer=n,this._showGeoCodingControl=r,this._showBoundaryBox=a,this._useZoomControls=o,this._showGeoJson=s,this._clusterConfig=l}setCenter(t){switch(this._center=eX(t),this._type){case"RASTER":if(this._mapJs){let t=eX(this._center)||(this._viewSettings?eX(this._viewSettings.center):void 0);t&&this._mapJs.setView(t,void 0,{pan:{animate:!1},zoom:{animate:!1}})}break;case"VECTOR":this._mapGl&&this._center&&this._mapGl.setCenter(this._center)}return this}flyTo(t,i){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":t||(t=this._center?this._center:this._viewSettings?this._viewSettings.center:void 0),i||(i=this._zoom?this._zoom:this._viewSettings&&this._viewSettings.zoom?this._viewSettings.zoom:void 0),this._mapGl?t&&this._mapGl.flyTo({center:t,zoom:i}):(this._center=t,this._zoom=i)}return this}resize(){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":this._mapGl&&this._mapGl.resize()}return this}setZoom(t){switch(this._zoom=t,this._type){case"RASTER":this._mapJs&&this._zoom&&this._mapJs.setZoom(this._zoom,{animate:!1});break;case"VECTOR":this._mapGl&&this._zoom&&this._mapGl.setZoom(this._zoom)}return this}setControls(t){return this._controls=t,this._mapGl&&(this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):this._mapGl.addControl(new ej.NavigationControl)),this}setGeoJson(t){var i;return this._geoJsonConfig=t,this._mapGl&&(this._geoJsonConfig?this._loadGeoJSON(this._geoJsonConfig):this._loadGeoJSON(null==(i=this._viewSettings)?void 0:i.geoJson)),this}loadViewSettings(){return e3(this,void 0,void 0,function*(){var t;let i=("RASTER"===this._type?yield k().rest.api.MapResource.getSettingsJs():yield k().rest.api.MapResource.getSettings()).data;if(i.override)return i.override;let n=k().displayRealm||"default";return this._viewSettings=i.options?i.options[n]?i.options[n]:i.options.default:null,this._viewSettings&&(this._mapGl&&(this._mapGl.setMinZoom(this._viewSettings.minZoom),this._mapGl.setMaxZoom(this._viewSettings.maxZoom),this._viewSettings.bounds&&this._mapGl.setMaxBounds(this._viewSettings.bounds),this._geoJsonConfig?yield this._loadGeoJSON(this._geoJsonConfig):yield this._loadGeoJSON(null==(t=this._viewSettings)?void 0:t.geoJson)),this._center?this.setCenter(this._center):this.setCenter(this._viewSettings.center)),i})}build(){return e3(this,void 0,void 0,function*(){var i;if(!this._loaded){if("RASTER"===this._type){let t,i=document.createElement("style");i.id="mapboxJsStyle",i.textContent=e4,this._styleParent.appendChild(i);let n=yield this.loadViewSettings();if(this._viewSettings){if((t={}).zoom=this._viewSettings.zoom?this._viewSettings.zoom+1:void 0,this._useZoomControls&&(t.maxZoom=this._viewSettings.maxZoom?this._viewSettings.maxZoom-1:void 0,t.minZoom=this._viewSettings.minZoom?this._viewSettings.minZoom+1:void 0),t.boxZoom=this._viewSettings.boxZoom,this._viewSettings.bounds&&(t.maxBounds=eK(this._viewSettings.bounds)),this._viewSettings.center){let i=eX(this._viewSettings.center);t.center=i?L.latLng(i.lat,i.lng):void 0}if(this._center){let i=eX(this._center);t.center=i?L.latLng(i.lat,i.lng):void 0}this._zoom&&(t.zoom=this._zoom+1)}if(this._mapJs=L.mapbox.map(this._mapContainer,n,t),this._mapJs.on("click",t=>{this._onMapClick(t.latlng)}),t&&t.maxBounds){let i=this._mapJs.getBoundsZoom(t.maxBounds,!0);(!t.minZoom||t.minZoom<i)&&this._mapJs.setMinZoom(i)}}else{let n=document.createElement("style");n.id="maplibreGlStyle",n.textContent=e6,this._styleParent.appendChild(n),(n=document.createElement("style")).id="maplibreGeoCoderStyles",n.textContent=e8,this._styleParent.appendChild(n);let r=yield Promise.resolve().then(c.t.bind(c,415,23)),a=yield this.loadViewSettings(),o={attributionControl:{compact:!0},container:this._mapContainer,style:a,transformRequest:(i,n)=>{if(t||(t=new URL(i).searchParams.get("access_token")||""),0===i.indexOf("mapbox:")){var r,a,o,s,l,c,d,h,u;let p,m,f,g,_,b,y,v;return r=t,i.indexOf("/styles/")>-1&&-1===i.indexOf("/sprite")?{url:(a=i,o=r,(p=e1(a)).path=`/styles/v1${p.path}`,e2(p,o))}:i.indexOf("/sprites/")>-1?{url:(s=i,l=r,g=(f=(m=e1(s)).path.split("."))[0],_=f[1],b="",g.indexOf("@2x")&&(g=g.split("@2x")[0],b="@2x"),m.path=`/styles/v1${g}/sprite${b}.${_}`,e2(m,l))}:i.indexOf("/fonts/")>-1?{url:(c=i,d=r,(y=e1(c)).path=`/fonts/v1${y.path}`,e2(y,d))}:i.indexOf("/v4/")>-1||"Source"===n?{url:(h=i,u=r,(v=e1(h)).path=`/v4/${v.authority}.json`,v.params.push("secure"),e2(v,u))}:void 0}return{headers:new URL(window.origin).hostname===new URL(i).hostname?{Authorization:k().getAuthorizationHeader()}:{},url:i}}};if(this._viewSettings&&(this._useZoomControls&&(o.maxZoom=this._viewSettings.maxZoom,o.minZoom=this._viewSettings.minZoom),this._viewSettings.bounds&&!this._showBoundaryBox&&(o.maxBounds=this._viewSettings.bounds),o.boxZoom=this._viewSettings.boxZoom,o.zoom=this._viewSettings.zoom,o.center=this._viewSettings.center),this._center=this._center||(this._viewSettings?this._viewSettings.center:void 0),o.center=this._center,this._zoom&&(o.zoom=this._zoom),!eQ())return void console.warn("WebGL is not supported in this environment. The map cannot be initialized.");this._mapGl=new r.Map(o),yield this._styleLoaded(),this._mapGl.on("click",t=>{this._onMapClick(t.lngLat)}),this._mapGl.on("dblclick",t=>{this._onMapClick(t.lngLat,!0)}),this._showGeoCodingControl&&this._viewSettings&&this._viewSettings.geocodeUrl&&(this._geocoder=new(eG())({forwardGeocode:this._forwardGeocode.bind(this),reverseGeocode:this._reverseGeocode},{maplibregl:eU(),showResultsWhileTyping:!0}),this._geocoder._onKeyDown=eH()(t=>{if(27===t.keyCode&&this._geocoder.options.clearAndBlurOnEsc)return this._geocoder._clear(t),this._geocoder._inputEl.blur();var i=this._geocoder._inputEl.value||t.key;if(!i)return this._geocoder.fresh=!0,9!==t.keyCode&&this._geocoder.clear(t),this._geocoder._clearEl.style.display="none";if(!t.metaKey&&-1===[9,27,37,39,38,40].indexOf(t.keyCode)){if(13===t.keyCode)if(this._geocoder.options.showResultsWhileTyping){this._geocoder.options.showResultMarkers&&this._geocoder._fitBoundsForMarkers(),this._geocoder._inputEl.value=this._geocoder._typeahead.query,this._geocoder.lastSelected=null,this._geocoder._typeahead.selected=null;return}else this._geocoder._typeahead.list.selectingListItem||this._geocoder._geocode(i);i.length>=this._geocoder.options.minLength&&this._geocoder.options.showResultsWhileTyping&&this._geocoder._geocode(i)}},300),this._mapGl.addControl(this._geocoder,"top-left"),this._geocoder._inputEl.addEventListener("change",()=>{var t=this._geocoder._typeahead.selected;this._onGeocodeChange(t)})),this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):(this._mapGl.addControl(new ej.NavigationControl),this._mapGl.addControl(new ej.GeolocateControl({positionOptions:{enableHighAccuracy:!0},showAccuracyCircle:!0,showUserLocation:!0}))),this._geoJsonConfig?yield this._loadGeoJSON(this._geoJsonConfig):yield this._loadGeoJSON(null==(i=this._viewSettings)?void 0:i.geoJson),this._initLongPressEvent(),this._mapGl.on("load",()=>e3(this,void 0,void 0,function*(){return yield this.load()}))}this._mapContainer.dispatchEvent(new rF),this._loaded=!0,this.createBoundaryBox()}})}_styleLoaded(){return new Promise(t=>{this._mapGl&&this._mapGl.once("style.load",t)})}load(){return e3(this,void 0,void 0,function*(){var t,i,n,r,a,o;this._mapGl&&this._loaded?(this._mapGl.getSource("mapPoints")&&(this._mapGl.getLayer("unclustered-point")&&this._mapGl.removeLayer("unclustered-point"),this._mapGl.getLayer("clusters")&&this._mapGl.removeLayer("clusters"),this._mapGl.getLayer("cluster-count")&&this._mapGl.removeLayer("cluster-count"),this._mapGl.removeSource("mapPoints")),this._mapGl.addSource("mapPoints",{type:"geojson",cluster:null==(i=null==(t=this._clusterConfig)?void 0:t.cluster)||i,clusterRadius:null!=(r=null==(n=this._clusterConfig)?void 0:n.clusterRadius)?r:180,clusterMaxZoom:null!=(o=null==(a=this._clusterConfig)?void 0:a.clusterMaxZoom)?o:17,data:this._pointsMap,clusterProperties:Object.fromEntries(Object.keys(this._assetTypeColors).map(t=>[t,["+",["case",["==",["get","assetType"],t],1,0]]]))}),this._mapGl.getLayer("unclustered-point")||this._mapGl.addLayer({id:"unclustered-point",type:"circle",source:"mapPoints",filter:["!",["has","point_count"]],paint:{"circle-radius":0}}),this._mapGl.on("data",t=>e3(this,void 0,void 0,function*(){!this._mapGl||"mapPoints"===t.sourceId&&t.isSourceLoaded&&(this._mapGl.off("move",()=>this._updateMarkers()),this._mapGl.off("moveend",()=>this._updateMarkers()),this._mapGl.on("move",eH()(()=>this._updateMarkers())),this._mapGl.on("moveend",()=>this._updateMarkers()),this._updateMarkers())}))):console.warn("MapLibre Map not initialized!")})}unload(){this._mapGl&&(this._mapGl.remove(),this._mapGl=void 0),this._mapJs&&(this._mapJs.remove(),this._mapJs=void 0)}_onMapClick(t,i=!1){this._mapContainer.dispatchEvent(new rB(t,i))}_loadGeoJSON(t){return e3(this,void 0,void 0,function*(){if(this._geoJsonLayers.size>0&&(this._geoJsonLayers.forEach((t,i)=>this._mapGl.removeLayer(i)),this._geoJsonLayers=new Map),this._geoJsonSources.length>0&&(this._geoJsonSources.forEach(t=>this._mapGl.removeSource(t)),this._geoJsonSources=[]),this._showGeoJson&&t)if("FeatureCollection"==t.source.type){let i=this.groupSourcesByGeometryType(t.source);null==i||i.forEach((t,i)=>{let n=this.addGeoJSONSource({type:"geojson",data:{type:"FeatureCollection",features:t}});n&&this.addGeoJSONLayer(i,n.sourceId)})}else if("Feature"==t.source.type){let i=this.addGeoJSONSource(t.source);i&&this.addGeoJSONLayer(i.source.type,i.sourceId)}else console.error("Could not create layer since source type is neither 'FeatureCollection' nor 'Feature'.")})}groupSourcesByGeometryType(t){let i=new Map;return t.features.forEach(t=>{let n=i.get(t.geometry.type);void 0==n&&(n=[]),n.push(t),i.set(t.geometry.type,n)}),i}addGeoJSONSource(t){if(!this._mapGl)return void console.error("mapGl instance not found!");let i=Date.now()+"-"+(this._geoJsonSources.length+1);return this._mapGl.addSource(i,t),this._geoJsonSources.push(i),{source:t,sourceId:i}}addGeoJSONLayer(t,i){if(!this._mapGl)return void console.error("mapGl instance not found!");let n=i+"-"+t;if(void 0==this._geoJsonLayers.get(n)){let r=getComputedStyle(this._mapContainer).getPropertyValue("--or-app-color4");(void 0==r||0==r.length)&&(r=w.DefaultColor4);let a={id:n,source:i};switch(t){case"Point":case"MultiPoint":a.type="circle",a.paint={"circle-radius":12,"circle-color":r},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);break;case"LineString":case"MultiLineString":a.type="line",a.paint={"line-color":r,"line-width":4},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);break;case"Polygon":case"MultiPolygon":{a.type="fill",a.paint={"fill-color":r,"fill-opacity":.3},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);let t=n+"-outline",o={id:t,source:i,type:"line",paint:{"line-color":r,"line-width":2}};this._geoJsonLayers.set(t,o),this._mapGl.addLayer(o);break}case"GeometryCollection":return void console.error("GeometryCollection GeoJSON is not implemented yet!")}}}addMarker(t){t.hasPosition()&&this._updateMarkerElement(t,!0)}_updateMarkers(){if(!this._mapGl)return;let t={},i=this._mapGl.querySourceFeatures("mapPoints");for(let n of i){if(!n.properties.id)continue;let i=n.properties.id,r=n.geometry.coordinates,a=this._cachedMarkers[i];if(!a){let t=document.createElement("div");a=this._cachedMarkers[i]=new(eU()).Marker({element:t}).setLngLat(r)}t[i]=a,this._markersOnScreen[i]||(a.addTo(this._mapGl),this._assetsOnScreen[i]=JSON.parse(n.properties.asset))}for(let n of i){if(!n.properties.cluster)continue;let i=n.properties.cluster_id,[r,a]=n.geometry.coordinates,o=this._cachedMarkers[i];if(!o){let t=Object.entries(n.properties).filter(([t])=>this._assetTypeColors.hasOwnProperty(t)).map(([t,i])=>[t,this._assetTypeColors[t],i]);o=this._cachedMarkers[i]=new(eU()).Marker({element:new e5(t,i,r,a,this._mapGl)}).setLngLat([r,a])}t[i]=o,this._markersOnScreen[i]||o.addTo(this._mapGl)}for(let i in this._markersOnScreen){let n=t[i];(!n||n._element instanceof e5&&!n._element.hasTypes(Object.keys(this._assetTypeColors)))&&(this._markersOnScreen[i].remove(),delete this._assetsOnScreen[i])}this._markersOnScreen=t,this._mapContainer.dispatchEvent(new rj(Object.values(this._assetsOnScreen)))}addAssetMarker(t,i,n,r,a,o){var s;this._assetTypeColors[n]=null==(s=eJ(n))?void 0:s.color,this._pointsMap.features.push({type:"Feature",properties:{name:i,id:t,assetType:n,asset:o},geometry:{type:"Point",coordinates:[r,a]}})}cleanUpAssetMarkers(){this._assetTypeColors={},this._pointsMap={type:"FeatureCollection",features:[]}}removeMarker(t){this._removeMarkerRadius(t),this._updateMarkerElement(t,!1)}onMarkerChanged(t,i){if(this._loaded)switch(i){case"lat":case"lng":case"radius":t.hasPosition()?t._actualMarkerElement?this._updateMarkerPosition(t):this._updateMarkerElement(t,!0):t._actualMarkerElement&&this._updateMarkerElement(t,!1)}}_updateMarkerPosition(t){switch(this._type){case"RASTER":let i=this._markersJs.get(t);i&&i.setLatLng([t.lat,t.lng]);break;case"VECTOR":let n=this._markersGl.get(t);n&&n.setLngLat([t.lng,t.lat])}this._createMarkerRadius(t)}_updateMarkerElement(t,i){switch(this._type){case"RASTER":let n=this._markersJs.get(t);if(n&&(this._removeMarkerClickHandler(t,t.markerContainer),t._actualMarkerElement=void 0,n.removeFrom(this._mapJs),this._markersJs.delete(t)),i){let i=t._createMarkerElement();if(i){let r=L.divIcon({html:i.outerHTML,className:"or-marker-raster"});(n=L.marker([t.lat,t.lng],{icon:r,clickable:t.interactive})).addTo(this._mapJs),t._actualMarkerElement=n.getElement()?n.getElement().firstElementChild:void 0,t.interactive&&this._addMarkerClickHandler(t,t.markerContainer),this._markersJs.set(t,n)}t.radius&&this._createMarkerRadius(t)}break;case"VECTOR":let r=this._markersGl.get(t);if(r&&(t._actualMarkerElement=void 0,this._removeMarkerClickHandler(t,r.getElement()),r.remove(),this._markersGl.delete(t)),i){let i=t._createMarkerElement();i&&(r=new ej.Marker({element:i,anchor:"top-left"}).setLngLat([t.lng,t.lat]).addTo(this._mapGl),this._markersGl.set(t,r),t._actualMarkerElement=r.getElement(),t.interactive&&this._addMarkerClickHandler(t,r.getElement())),t.radius&&this._createMarkerRadius(t)}}}_removeMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&this._mapGl.getSource("circleData")&&(this._mapGl.removeLayer("marker-radius-circle"),this._mapGl.removeSource("circleData"))}_createMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&(this._removeMarkerRadius(t),this._mapGl.addSource("circleData",{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{title:"You Found Me"}}]}}),this._mapGl.addLayer({id:"marker-radius-circle",type:"circle",source:"circleData",paint:{"circle-radius":["interpolate",["linear"],["zoom"],0,0,20,t.radius/.075/Math.cos(t.lat*Math.PI/180)],"circle-color":"red","circle-opacity":.3}}))}createBoundaryBox(t=[]){var i,n;if(this._mapGl&&this._loaded&&this._showBoundaryBox&&(null==(i=this._viewSettings)?void 0:i.bounds)){this._mapGl.getSource("bounds")&&(this._mapGl.removeLayer("bounds"),this._mapGl.removeSource("bounds")),4!==t.length&&(t=null==(n=this._viewSettings)?void 0:n.bounds.toString().split(","));var r=[[[t[0],t[3]],[t[2],t[3]],[t[2],t[1]],[t[0],t[1]],[t[0],t[3]]]];this._mapGl.fitBounds([parseFloat(t[0])+.01,parseFloat(t[1])-.01,parseFloat(t[2])-.01,parseFloat(t[3])+.01]),this._mapGl.addSource("bounds",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:r}}}),this._mapGl.addLayer({id:"bounds",type:"fill",source:"bounds",paint:{"fill-color":"#FF0000","fill-opacity":.4}})}}_addMarkerClickHandler(t,i){if(i){let n=i=>{i.stopPropagation(),t._onClick(i)};this._clickHandlers.set(t,n),i.addEventListener("click",n)}}_removeMarkerClickHandler(t,i){let n=this._clickHandlers.get(t);n&&i&&(i.removeEventListener("click",n),this._clickHandlers.delete(t))}_forwardGeocode(t){return e3(this,void 0,void 0,function*(){let i=[];try{let n=this._viewSettings.geocodeUrl+"/search?q="+t.query+"&format=geojson&polygon_geojson=1&addressdetails=1",r=yield fetch(n);for(let t of(yield r.json()).features){let n=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],r={type:"Feature",geometry:{type:"Point",coordinates:n},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:n};i.push(r)}}catch(t){console.error(`Failed to forwardGeocode with error: ${t}`)}return{features:i}})}_reverseGeocode(t){return e3(this,void 0,void 0,function*(){let i=[];try{let n=this._viewSettings.geocodeUrl+"/reverse?lat="+t.lat+"&lon="+t.lon+"&format=geojson&polygon_geojson=1&addressdetails=1",r=yield fetch(n);for(let t of(yield r.json()).features){let n=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],r={type:"Feature",geometry:{type:"Point",coordinates:n},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:n};i.push(r)}}catch(t){console.error(`Failed to reverseGeocode with error: ${t}`)}return{features:i}})}_initLongPressEvent(){if(this._mapGl){let t,i,n=()=>{t&&clearTimeout(t),t=null};this._mapGl.on("touchstart",n=>{n.originalEvent.touches.length>1||(i=n.lngLat,t=setTimeout(()=>{this._onLongPress(i)},500))}),this._mapGl.on("mousedown",n=>{t||(i=n.lngLat,t=setTimeout(()=>{this._onLongPress(i),t=null},500))}),this._mapGl.on("dragstart",n),this._mapGl.on("mouseup",n),this._mapGl.on("touchend",n),this._mapGl.on("touchcancel",n),this._mapGl.on("touchmove",n),this._mapGl.on("moveend",n),this._mapGl.on("gesturestart",n),this._mapGl.on("gesturechange",n),this._mapGl.on("gestureend",n)}}_onLongPress(t){this._mapContainer.dispatchEvent(new rN(t))}_onGeocodeChange(t){this._mapContainer.dispatchEvent(new rV(t))}}let e9="--internal-or-map-marker-color",te="--internal-or-map-marker-active-color",tt=M`
|
|
74
|
+
/>`}connectedCallback(){super.connectedCallback(),this.addEventListener("click",this.onClick)}disconnectedCallback(){super.disconnectedCallback(),this.removeEventListener("click",this.onClick)}onClick(){var t,i,n,r;return t=this,i=void 0,n=void 0,r=function*(){if(this.lng&&this.lat){let t=yield this._map.getSource("mapPoints").getClusterExpansionZoom(this._clusterId);this._map.easeTo({center:[this.lng,this.lat],zoom:t+.99,essential:!0})}},new(n||(n=Promise))(function(a,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function l(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var i;t.done?a(t.value):((i=t.value)instanceof n?i:new n(function(t){t(i)})).then(s,l)}c((r=r.apply(t,i||[])).next())})}};e5=function(t,i,n,r){var a,o=arguments.length,s=o<3?i:null===r?r=Object.getOwnPropertyDescriptor(i,n):r;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)s=Reflect.decorate(t,i,n,r);else for(var l=t.length-1;l>=0;l--)(a=t[l])&&(s=(o<3?a(s):o>3?a(i,n,s):a(i,n))||s);return o>3&&s&&Object.defineProperty(i,n,s),s}([eR("or-cluster-marker")],e5);var e3=function(t,i,n,r){return new(n||(n=Promise))(function(a,o){function s(t){try{c(r.next(t))}catch(t){o(t)}}function l(t){try{c(r.throw(t))}catch(t){o(t)}}function c(t){var i;t.done?a(t.value):((i=t.value)instanceof n?i:new n(function(t){t(i)})).then(s,l)}c((r=r.apply(t,i||[])).next())})};let e4=c(977),e6=c(126),e8=c(561);class e7{constructor(t,i,n,r=!1,a=!1,o=!0,s=!0,l){this._loaded=!1,this._markersJs=new Map,this._markersGl=new Map,this._geoJsonSources=[],this._geoJsonLayers=new Map,this._showGeoCodingControl=!1,this._showBoundaryBox=!1,this._useZoomControls=!0,this._showGeoJson=!0,this._clickHandlers=new Map,this._pointsMap={type:"FeatureCollection",features:[]},this._assetTypeColors={},this._cachedMarkers={},this._markersOnScreen={},this._assetsOnScreen={},this._type=t,this._styleParent=i,this._mapContainer=n,this._showGeoCodingControl=r,this._showBoundaryBox=a,this._useZoomControls=o,this._showGeoJson=s,this._clusterConfig=l}setCenter(t){switch(this._center=eX(t),this._type){case"RASTER":if(this._mapJs){let t=eX(this._center)||(this._viewSettings?eX(this._viewSettings.center):void 0);t&&this._mapJs.setView(t,void 0,{pan:{animate:!1},zoom:{animate:!1}})}break;case"VECTOR":this._mapGl&&this._center&&this._mapGl.setCenter(this._center)}return this}flyTo(t,i){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":t||(t=this._center?this._center:this._viewSettings?this._viewSettings.center:void 0),i||(i=this._zoom?this._zoom:this._viewSettings&&this._viewSettings.zoom?this._viewSettings.zoom:void 0),this._mapGl?t&&this._mapGl.flyTo({center:t,zoom:i}):(this._center=t,this._zoom=i)}return this}resize(){switch(this._type){case"RASTER":this._mapJs;break;case"VECTOR":this._mapGl&&this._mapGl.resize()}return this}setZoom(t){switch(this._zoom=t,this._type){case"RASTER":this._mapJs&&this._zoom&&this._mapJs.setZoom(this._zoom,{animate:!1});break;case"VECTOR":this._mapGl&&this._zoom&&this._mapGl.setZoom(this._zoom)}return this}setControls(t){return this._controls=t,this._mapGl&&(this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):this._mapGl.addControl(new ej.NavigationControl)),this}setGeoJson(t){var i;return this._geoJsonConfig=t,this._mapGl&&(this._geoJsonConfig?this._loadGeoJSON(this._geoJsonConfig):this._loadGeoJSON(null==(i=this._viewSettings)?void 0:i.geoJson)),this}loadViewSettings(){return e3(this,void 0,void 0,function*(){var t;let i=("RASTER"===this._type?yield k().rest.api.MapResource.getSettingsJs():yield k().rest.api.MapResource.getSettings()).data;if(i.override)return i.override;let n=k().displayRealm||"default";return this._viewSettings=i.options?i.options[n]?i.options[n]:i.options.default:null,this._viewSettings&&(this._mapGl&&(this._mapGl.setMinZoom(this._viewSettings.minZoom),this._mapGl.setMaxZoom(this._viewSettings.maxZoom),this._viewSettings.bounds&&this._mapGl.setMaxBounds(this._viewSettings.bounds),this._geoJsonConfig?yield this._loadGeoJSON(this._geoJsonConfig):yield this._loadGeoJSON(null==(t=this._viewSettings)?void 0:t.geoJson)),this._center?this.setCenter(this._center):this.setCenter(this._viewSettings.center)),i})}build(){return e3(this,void 0,void 0,function*(){var i;if(!this._loaded){if("RASTER"===this._type){let t,i=document.createElement("style");i.id="mapboxJsStyle",i.textContent=e4,this._styleParent.appendChild(i);let n=yield this.loadViewSettings();if(this._viewSettings){if((t={}).zoom=this._viewSettings.zoom?this._viewSettings.zoom+1:void 0,this._useZoomControls&&(t.maxZoom=this._viewSettings.maxZoom?this._viewSettings.maxZoom-1:void 0,t.minZoom=this._viewSettings.minZoom?this._viewSettings.minZoom+1:void 0),t.boxZoom=this._viewSettings.boxZoom,this._viewSettings.bounds&&(t.maxBounds=eK(this._viewSettings.bounds)),this._viewSettings.center){let i=eX(this._viewSettings.center);t.center=i?L.latLng(i.lat,i.lng):void 0}if(this._center){let i=eX(this._center);t.center=i?L.latLng(i.lat,i.lng):void 0}this._zoom&&(t.zoom=this._zoom+1)}if(this._mapJs=L.mapbox.map(this._mapContainer,n,t),this._mapJs.on("click",t=>{this._onMapClick(t.latlng)}),t&&t.maxBounds){let i=this._mapJs.getBoundsZoom(t.maxBounds,!0);(!t.minZoom||t.minZoom<i)&&this._mapJs.setMinZoom(i)}}else{let n=document.createElement("style");n.id="maplibreGlStyle",n.textContent=e6,this._styleParent.appendChild(n),(n=document.createElement("style")).id="maplibreGeoCoderStyles",n.textContent=e8,this._styleParent.appendChild(n);let r=yield Promise.resolve().then(c.t.bind(c,415,23)),a=yield this.loadViewSettings(),o={attributionControl:{compact:!0},container:this._mapContainer,style:a,transformRequest:(i,n)=>{if(t||(t=new URL(i).searchParams.get("access_token")||""),0===i.indexOf("mapbox:")){var r,a,o,s,l,c,d,h,u;let p,m,f,g,_,b,y,v;return r=t,i.indexOf("/styles/")>-1&&-1===i.indexOf("/sprite")?{url:(a=i,o=r,(p=e1(a)).path=`/styles/v1${p.path}`,e2(p,o))}:i.indexOf("/sprites/")>-1?{url:(s=i,l=r,g=(f=(m=e1(s)).path.split("."))[0],_=f[1],b="",g.indexOf("@2x")&&(g=g.split("@2x")[0],b="@2x"),m.path=`/styles/v1${g}/sprite${b}.${_}`,e2(m,l))}:i.indexOf("/fonts/")>-1?{url:(c=i,d=r,(y=e1(c)).path=`/fonts/v1${y.path}`,e2(y,d))}:i.indexOf("/v4/")>-1||"Source"===n?{url:(h=i,u=r,(v=e1(h)).path=`/v4/${v.authority}.json`,v.params.push("secure"),e2(v,u))}:void 0}return{headers:new URL(window.origin).hostname===new URL(i).hostname?{Authorization:k().getAuthorizationHeader()}:{},url:i}}};if(this._viewSettings&&(this._useZoomControls&&(o.maxZoom=this._viewSettings.maxZoom,o.minZoom=this._viewSettings.minZoom),this._viewSettings.bounds&&!this._showBoundaryBox&&(o.maxBounds=this._viewSettings.bounds),o.boxZoom=this._viewSettings.boxZoom,o.zoom=this._viewSettings.zoom,o.center=this._viewSettings.center),this._center=this._center||(this._viewSettings?this._viewSettings.center:void 0),o.center=this._center,this._zoom&&(o.zoom=this._zoom),!eQ())return void console.warn("WebGL is not supported in this environment. The map cannot be initialized.");this._mapGl=new r.Map(o),yield this._styleLoaded(),this._mapGl.on("click",t=>{this._onMapClick(t.lngLat)}),this._mapGl.on("dblclick",t=>{this._onMapClick(t.lngLat,!0)}),this._showGeoCodingControl&&this._viewSettings&&this._viewSettings.geocodeUrl&&(this._geocoder=new(eG())({forwardGeocode:this._forwardGeocode.bind(this),reverseGeocode:this._reverseGeocode},{maplibregl:eU(),showResultsWhileTyping:!0}),this._geocoder._onKeyDown=eH()(t=>{if(27===t.keyCode&&this._geocoder.options.clearAndBlurOnEsc)return this._geocoder._clear(t),this._geocoder._inputEl.blur();var i=this._geocoder._inputEl.value||t.key;if(!i)return this._geocoder.fresh=!0,9!==t.keyCode&&this._geocoder.clear(t),this._geocoder._clearEl.style.display="none";if(!t.metaKey&&-1===[9,27,37,39,38,40].indexOf(t.keyCode)){if(13===t.keyCode)if(this._geocoder.options.showResultsWhileTyping){this._geocoder.options.showResultMarkers&&this._geocoder._fitBoundsForMarkers(),this._geocoder._inputEl.value=this._geocoder._typeahead.query,this._geocoder.lastSelected=null,this._geocoder._typeahead.selected=null;return}else this._geocoder._typeahead.list.selectingListItem||this._geocoder._geocode(i);i.length>=this._geocoder.options.minLength&&this._geocoder.options.showResultsWhileTyping&&this._geocoder._geocode(i)}},300),this._mapGl.addControl(this._geocoder,"top-left"),this._geocoder._inputEl.addEventListener("change",()=>{var t=this._geocoder._typeahead.selected;this._onGeocodeChange(t)})),this._controls?this._controls.forEach(t=>{Array.isArray(t)?this._mapGl.addControl(t[0],t[1]):this._mapGl.addControl(t)}):(this._mapGl.addControl(new ej.NavigationControl),this._mapGl.addControl(new ej.GeolocateControl({positionOptions:{enableHighAccuracy:!0},showAccuracyCircle:!0,showUserLocation:!0}))),this._geoJsonConfig?yield this._loadGeoJSON(this._geoJsonConfig):yield this._loadGeoJSON(null==(i=this._viewSettings)?void 0:i.geoJson),this._initLongPressEvent(),this._mapGl.on("load",()=>e3(this,void 0,void 0,function*(){return yield this.load()}))}this._mapContainer.dispatchEvent(new rF),this._loaded=!0,this.createBoundaryBox()}})}_styleLoaded(){return new Promise(t=>{this._mapGl&&this._mapGl.once("style.load",t)})}load(){return e3(this,void 0,void 0,function*(){var t,i,n,r,a,o;this._mapGl&&this._loaded?(this._mapGl.getSource("mapPoints")&&(this._mapGl.getLayer("unclustered-point")&&this._mapGl.removeLayer("unclustered-point"),this._mapGl.getLayer("clusters")&&this._mapGl.removeLayer("clusters"),this._mapGl.getLayer("cluster-count")&&this._mapGl.removeLayer("cluster-count"),this._mapGl.removeSource("mapPoints")),this._mapGl.addSource("mapPoints",{type:"geojson",cluster:null==(i=null==(t=this._clusterConfig)?void 0:t.cluster)||i,clusterRadius:null!=(r=null==(n=this._clusterConfig)?void 0:n.clusterRadius)?r:180,clusterMaxZoom:null!=(o=null==(a=this._clusterConfig)?void 0:a.clusterMaxZoom)?o:17,data:this._pointsMap,clusterProperties:Object.fromEntries(Object.keys(this._assetTypeColors).map(t=>[t,["+",["case",["==",["get","assetType"],t],1,0]]]))}),this._mapGl.getLayer("unclustered-point")||this._mapGl.addLayer({id:"unclustered-point",type:"circle",source:"mapPoints",filter:["!",["has","point_count"]],paint:{"circle-radius":0}}),this._mapGl.on("data",t=>e3(this,void 0,void 0,function*(){!this._mapGl||"mapPoints"===t.sourceId&&t.isSourceLoaded&&(this._mapGl.off("move",()=>this._updateMarkers()),this._mapGl.off("moveend",()=>this._updateMarkers()),this._mapGl.on("move",eH()(()=>this._updateMarkers())),this._mapGl.on("moveend",()=>this._updateMarkers()),this._updateMarkers())}))):console.warn("MapLibre Map not initialized!")})}unload(){this._mapGl&&(this._mapGl.remove(),this._mapGl=void 0),this._mapJs&&(this._mapJs.remove(),this._mapJs=void 0)}_onMapClick(t,i=!1){this._mapContainer.dispatchEvent(new rB(t,i))}_loadGeoJSON(t){return e3(this,void 0,void 0,function*(){if(this._geoJsonLayers.size>0&&(this._geoJsonLayers.forEach((t,i)=>this._mapGl.removeLayer(i)),this._geoJsonLayers=new Map),this._geoJsonSources.length>0&&(this._geoJsonSources.forEach(t=>this._mapGl.removeSource(t)),this._geoJsonSources=[]),this._showGeoJson&&t)if("FeatureCollection"==t.source.type){let i=this.groupSourcesByGeometryType(t.source);null==i||i.forEach((t,i)=>{let n=this.addGeoJSONSource({type:"geojson",data:{type:"FeatureCollection",features:t}});n&&this.addGeoJSONLayer(i,n.sourceId)})}else if("Feature"==t.source.type){let i=this.addGeoJSONSource(t.source);i&&this.addGeoJSONLayer(i.source.type,i.sourceId)}else console.error("Could not create layer since source type is neither 'FeatureCollection' nor 'Feature'.")})}groupSourcesByGeometryType(t){let i=new Map;return t.features.forEach(t=>{let n=i.get(t.geometry.type);void 0==n&&(n=[]),n.push(t),i.set(t.geometry.type,n)}),i}addGeoJSONSource(t){if(!this._mapGl)return void console.error("mapGl instance not found!");let i=Date.now()+"-"+(this._geoJsonSources.length+1);return this._mapGl.addSource(i,t),this._geoJsonSources.push(i),{source:t,sourceId:i}}addGeoJSONLayer(t,i){if(!this._mapGl)return void console.error("mapGl instance not found!");let n=i+"-"+t;if(void 0==this._geoJsonLayers.get(n)){let r=getComputedStyle(this._mapContainer).getPropertyValue("--or-app-color4");(void 0==r||0==r.length)&&(r=w.DefaultColor4);let a={id:n,source:i};switch(t){case"Point":case"MultiPoint":a.type="circle",a.paint={"circle-radius":12,"circle-color":r},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);break;case"LineString":case"MultiLineString":a.type="line",a.paint={"line-color":r,"line-width":4},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);break;case"Polygon":case"MultiPolygon":{a.type="fill",a.paint={"fill-color":r,"fill-opacity":.3},this._geoJsonLayers.set(n,a),this._mapGl.addLayer(a);let t=n+"-outline",o={id:t,source:i,type:"line",paint:{"line-color":r,"line-width":2}};this._geoJsonLayers.set(t,o),this._mapGl.addLayer(o);break}case"GeometryCollection":return void console.error("GeometryCollection GeoJSON is not implemented yet!")}}}addMarker(t){t.hasPosition()&&this._updateMarkerElement(t,!0)}_updateMarkers(){if(!this._mapGl)return;let t={},i=this._mapGl.querySourceFeatures("mapPoints");for(let n of i){if(!n.properties.id)continue;let i=n.properties.id,r=n.geometry.coordinates,a=this._cachedMarkers[i];if(!a){let t=document.createElement("div");a=this._cachedMarkers[i]=new(eU()).Marker({element:t}).setLngLat(r)}t[i]=a,this._markersOnScreen[i]||(a.addTo(this._mapGl),this._assetsOnScreen[i]=JSON.parse(n.properties.asset))}for(let n of i){if(!n.properties.cluster)continue;let i=n.properties.cluster_id,[r,a]=n.geometry.coordinates,o=this._cachedMarkers[i];if(!o){let t=Object.entries(n.properties).filter(([t])=>this._assetTypeColors.hasOwnProperty(t)).map(([t,i])=>[t,this._assetTypeColors[t],i]);o=this._cachedMarkers[i]=new(eU()).Marker({element:new e5(t,i,r,a,this._mapGl)}).setLngLat([r,a])}t[i]=o,this._markersOnScreen[i]||o.addTo(this._mapGl)}for(let i in this._markersOnScreen){let n=t[i];(!n||n._element instanceof e5&&!n._element.hasTypes(Object.keys(this._assetTypeColors)))&&(this._markersOnScreen[i].remove(),delete this._assetsOnScreen[i])}this._markersOnScreen=t,this._mapContainer.dispatchEvent(new rj(Object.values(this._assetsOnScreen)))}addAssetMarker(t,i,n,r,a,o){var s;this._assetTypeColors[n]=null==(s=eJ(n))?void 0:s.color,this._pointsMap.features.push({type:"Feature",properties:{name:i,id:t,assetType:n,asset:o},geometry:{type:"Point",coordinates:[r,a]}})}cleanUpAssetMarkers(){this._assetTypeColors={},this._pointsMap={type:"FeatureCollection",features:[]}}removeMarker(t){this._removeMarkerRadius(t),this._updateMarkerElement(t,!1)}onMarkerChanged(t,i){if(this._loaded)switch(i){case"lat":case"lng":case"radius":t.hasPosition()?t._actualMarkerElement?this._updateMarkerPosition(t):this._updateMarkerElement(t,!0):t._actualMarkerElement&&this._updateMarkerElement(t,!1)}}_updateMarkerPosition(t){switch(this._type){case"RASTER":let i=this._markersJs.get(t);i&&i.setLatLng([t.lat,t.lng]);break;case"VECTOR":let n=this._markersGl.get(t);n&&n.setLngLat([t.lng,t.lat])}this._createMarkerRadius(t)}_updateMarkerElement(t,i){switch(this._type){case"RASTER":let n=this._markersJs.get(t);if(n&&(this._removeMarkerClickHandler(t,t.markerContainer),t._actualMarkerElement=void 0,n.removeFrom(this._mapJs),this._markersJs.delete(t)),i){let i=t._createMarkerElement();if(i){let r=L.divIcon({html:i.outerHTML,className:"or-marker-raster"});(n=L.marker([t.lat,t.lng],{icon:r,clickable:t.interactive})).addTo(this._mapJs),t._actualMarkerElement=n.getElement()?n.getElement().firstElementChild:void 0,t.interactive&&this._addMarkerClickHandler(t,t.markerContainer),this._markersJs.set(t,n)}t.radius&&this._createMarkerRadius(t)}break;case"VECTOR":let r=this._markersGl.get(t);if(r&&(t._actualMarkerElement=void 0,this._removeMarkerClickHandler(t,r.getElement()),r.remove(),this._markersGl.delete(t)),i){let i=t._createMarkerElement();i&&(r=new ej.Marker({element:i,anchor:"top-left"}).setLngLat([t.lng,t.lat]).addTo(this._mapGl),this._markersGl.set(t,r),t._actualMarkerElement=r.getElement(),t.interactive&&this._addMarkerClickHandler(t,r.getElement())),t.radius&&this._createMarkerRadius(t)}}}_removeMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&this._mapGl.getSource("circleData")&&(this._mapGl.removeLayer("marker-radius-circle"),this._mapGl.removeSource("circleData"))}_createMarkerRadius(t){this._mapGl&&this._loaded&&t.radius&&t.lat&&t.lng&&(this._removeMarkerRadius(t),this._mapGl.addSource("circleData",{type:"geojson",data:{type:"FeatureCollection",features:[{type:"Feature",geometry:{type:"Point",coordinates:[t.lng,t.lat]},properties:{}}]}}),this._mapGl.addLayer({id:"marker-radius-circle",type:"circle",source:"circleData",paint:{"circle-radius":["interpolate",["exponential",2],["zoom"],0,0,20,t.radius/.075/Math.cos(t.lat*Math.PI/180)],"circle-color":"red","circle-opacity":.3,"circle-pitch-alignment":"map"}}))}createBoundaryBox(t=[]){var i,n;if(this._mapGl&&this._loaded&&this._showBoundaryBox&&(null==(i=this._viewSettings)?void 0:i.bounds)){this._mapGl.getSource("bounds")&&(this._mapGl.removeLayer("bounds"),this._mapGl.removeSource("bounds")),4!==t.length&&(t=null==(n=this._viewSettings)?void 0:n.bounds.toString().split(","));var r=[[[t[0],t[3]],[t[2],t[3]],[t[2],t[1]],[t[0],t[1]],[t[0],t[3]]]];this._mapGl.fitBounds([parseFloat(t[0])+.01,parseFloat(t[1])-.01,parseFloat(t[2])-.01,parseFloat(t[3])+.01]),this._mapGl.addSource("bounds",{type:"geojson",data:{type:"Feature",properties:{},geometry:{type:"Polygon",coordinates:r}}}),this._mapGl.addLayer({id:"bounds",type:"fill",source:"bounds",paint:{"fill-color":"#FF0000","fill-opacity":.4}})}}_addMarkerClickHandler(t,i){if(i){let n=i=>{i.stopPropagation(),t._onClick(i)};this._clickHandlers.set(t,n),i.addEventListener("click",n)}}_removeMarkerClickHandler(t,i){let n=this._clickHandlers.get(t);n&&i&&(i.removeEventListener("click",n),this._clickHandlers.delete(t))}_forwardGeocode(t){return e3(this,void 0,void 0,function*(){let i=[];try{let n=this._viewSettings.geocodeUrl+"/search?q="+t.query+"&format=geojson&polygon_geojson=1&addressdetails=1",r=yield fetch(n);for(let t of(yield r.json()).features){let n=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],r={type:"Feature",geometry:{type:"Point",coordinates:n},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:n};i.push(r)}}catch(t){console.error(`Failed to forwardGeocode with error: ${t}`)}return{features:i}})}_reverseGeocode(t){return e3(this,void 0,void 0,function*(){let i=[];try{let n=this._viewSettings.geocodeUrl+"/reverse?lat="+t.lat+"&lon="+t.lon+"&format=geojson&polygon_geojson=1&addressdetails=1",r=yield fetch(n);for(let t of(yield r.json()).features){let n=[t.bbox[0]+(t.bbox[2]-t.bbox[0])/2,t.bbox[1]+(t.bbox[3]-t.bbox[1])/2],r={type:"Feature",geometry:{type:"Point",coordinates:n},place_name:t.properties.display_name,properties:t.properties,text:t.properties.display_name,place_type:["place"],center:n};i.push(r)}}catch(t){console.error(`Failed to reverseGeocode with error: ${t}`)}return{features:i}})}_initLongPressEvent(){if(this._mapGl){let t,i,n=()=>{t&&clearTimeout(t),t=null};this._mapGl.on("touchstart",n=>{n.originalEvent.touches.length>1||(i=n.lngLat,t=setTimeout(()=>{this._onLongPress(i)},500))}),this._mapGl.on("mousedown",n=>{t||(i=n.lngLat,t=setTimeout(()=>{this._onLongPress(i),t=null},500))}),this._mapGl.on("dragstart",n),this._mapGl.on("mouseup",n),this._mapGl.on("touchend",n),this._mapGl.on("touchcancel",n),this._mapGl.on("touchmove",n),this._mapGl.on("moveend",n),this._mapGl.on("gesturestart",n),this._mapGl.on("gesturechange",n),this._mapGl.on("gestureend",n)}}_onLongPress(t){this._mapContainer.dispatchEvent(new rN(t))}_onGeocodeChange(t){this._mapContainer.dispatchEvent(new rV(t))}}let e9="--internal-or-map-marker-color",te="--internal-or-map-marker-active-color",tt=M`
|
|
75
75
|
:host {
|
|
76
76
|
--internal-or-map-width: var(--or-map-width, 100%);
|
|
77
77
|
--internal-or-map-min-height: var(--or-map-min-height, 300px);
|