UNPKG

@expofp/floorplan

Version:

Interactive floor plan library for expos and events

2 lines (1 loc) • 1.39 kB
import{getFpGeo as p}from"../../../data/fpGeo.js";import u,{uiState as s}from"../../../store/index.js";import a from"../../../tools/settings.js";import{MAP_DIM_LAYER_ID as f}from"../MaplibreWrapper.js";import{DARK_MATTER_PAINT as m,POSITRON_PAINT as y,recolorStyle as c}from"./basemap-palette.js";import{resolveMapTheme as h}from"./map-theme.js";export const LIGHT_TILE_SOURCE={style:"https://tiles.openfreemap.org/styles/positron",restyle:t=>c(t,y)},DARK_TILE_SOURCE={style:"https://tiles.openfreemap.org/styles/dark",restyle:t=>c(t,m)},MAP_MIN_ZOOM=12;export function applyMapDimValue(t,e){t?.getLayer(f)&&(t.setPaintProperty(f,"fill-opacity",M(e)),t.triggerRepaint())}function M(t){return Math.min(Math.max(t,0),1)}export function applyMapOptions(t,e){if(!t)return;t.setMinZoom(e.minZoom??null),t.setMaxZoom(e.maxZoom??null),t.setMaxBounds(e.maxBounds??null);const{pitch:o,maxPitch:r}=e,i=s.animatePitch,n=t.getPitch(),l=!!(i&&o!=null&&r!=null&&r<n);l||t.setMaxPitch(r??null),!(o==null||n===o)&&(i?(t.easeTo({pitch:o,duration:s.mapSettings.pitchtime}),l&&t.once("moveend",()=>t.setMaxPitch(r))):t.jumpTo({pitch:o}))}export function getTileSource(){const t=u.fp?.maplibre??window.__efpMaplibre;return t?.style?{style:t.style,offline:t.offline}:t?.styleUrl?{style:t.styleUrl,offline:t.offline}:h(p()?.properties?.config?.style,a.backgroundColor)==="dark"?DARK_TILE_SOURCE:LIGHT_TILE_SOURCE}