@expofp/floorplan
Version:
Interactive floor plan library for expos and events
2 lines (1 loc) • 1.29 kB
JavaScript
import{fpGeo as a}from"../../../data/fpGeo.js";import f,{uiState as s}from"../../../store/index.js";import u from"../../../tools/settings.js";import{MAP_DIM_LAYER_ID as c}from"../MaplibreWrapper.js";import{resolveMapTheme as p}from"./map-theme.js";export const LIGHT_TILE_SOURCE={style:"https://basemaps.cartocdn.com/gl/positron-gl-style/style.json"},DARK_TILE_SOURCE={style:"https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json"},MAP_MIN_ZOOM=12;export function applyMapDimValue(t,e){t?.getLayer(c)&&(t.setPaintProperty(c,"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:n}=e,r=s.animatePitch,i=t.getPitch(),l=!!(r&&o!=null&&n!=null&&n<i);l||t.setMaxPitch(n??null),!(o==null||i===o)&&(r?(t.easeTo({pitch:o,duration:s.mapSettings.pitchtime}),l&&t.once("moveend",()=>t.setMaxPitch(n))):t.jumpTo({pitch:o}))}export function getTileSource(){const t=f.fp?.maplibre??window.__efpMaplibre;return t?.style?{style:t.style,offline:t.offline}:t?.styleUrl?{style:t.styleUrl,offline:t.offline}:p(a?.properties?.config?.style,u.backgroundColor)==="dark"?DARK_TILE_SOURCE:LIGHT_TILE_SOURCE}