solid-map-gl 1.8.1 → 1.8.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/esm/index.js CHANGED
@@ -1,2 +1,2 @@
1
- import{createComponent as e,use as t,effect as o,setAttribute as a,className as r,classList as n,style as i,memo as s,template as p}from"solid-js/web";import{createContext as l,useContext as c,createUniqueId as d,createSignal as m,createEffect as g,onMount as u,on as h,onCleanup as y,untrack as b}from"solid-js";import{createStore as f}from"solid-js/store";const[v,w]=f({map:null,userInteraction:!1}),k=l([v]),$=()=>c(k),L=t=>(t.map&&w("map",t.map),t.userInteraction&&w("userInteraction",t.userInteraction),e(k.Provider,{value:[v],get children(){return t.children}})),x=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],M=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],S=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"],j="mapbox://styles/mapbox",_="https://raw.githubusercontent.com/",z="https://raw.githubusercontent.com/GIShub4/map-styles/main/",I="https://assets.vector.hereapi.com/styles/",C={mb:{light:`${j}/light-v11`,dark:`${j}/dark-v11`,street:`${j}/streets-v12`,outdoor:`${j}/outdoors-v12`,sat:`${j}/satellite-v9`,sat_street:`${j}/satellite-streets-v12`,nav:`${j}/navigation-guidance-day-v4`,nav_night:`${j}/navigation-guidance-night-v4`,basic:`${j}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${j}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${j}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${j}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${j}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${j}/cj44mfrt20f082snokim4ungi`,mineral:`${j}/cjtep62gq54l21frr1whf27ak`,moonlight:`${j}/cj3kbeqzo00022smj7akz3o1e`,frank:`${j}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${j}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${j}-map-design/ck4014y110wt61ctt07egsel6`,standard:`${j}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${j}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${j}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${j}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${_}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${_}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${_}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${_}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${_}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${_}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${_}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${_}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${I}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${I}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${I}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${z}esri:blueprint.json`,charted_territory:`${z}esri:charted-territory.json`,colored_pencil:`${z}esri:colored-pencil.json`,community:`${z}esri:community.json`,mid_century:`${z}esri:mid-century.json`,modern_antique:`${z}esri:modern-antique.json`,nat_geo:`${z}esri:national-geographic.json`,newspaper:`${z}esri:newspaper.json`,open_street_map:`${z}esri:open-street-map.json`,light_gray_canvas:`${z}esri:light-gray-canvas.json`,dark_gray_canvas:`${z}esri:dark-gray-canvas.json`,human_geo_light:`${z}esri:human-geography-light.json`,human_geo_dark:`${z}esri:human-geography-dark.json`,world_navigation:`${z}esri:world-navigation.json`,world_street:`${z}esri:world-street.json`,world_street_night:`${z}esri:world-street-night.json`,world_terrain:`${z}esri:world-terrain.json`,world_terrain_hybrid:`${z}esri:world-terrain-hybrid.json`,world_topographic:`${z}esri:world-topographic.json`,chromium:`${z}esri:chromium.json`,dreamcatcher:`${z}esri:dreamcatcher.json`,seahaven:`${z}esri:seahaven.json`,sangria:`${z}esri:sangria.json`,mercurial:`${z}esri:mercurial.json`,imagery:`${z}esri:imagery.json`,imagery_hybrid:`${z}esri:imagery-hybrid.json`,firefly:`${z}esri:firefly.json`,firefly_hybrid:`${z}esri:firefly-hybrid.json`,oceans:`${z}esri:oceans.json`}},E="https://{s}.basemaps.cartocdn.com/rastertiles/",T="https://stamen-tiles-{s}.a.ssl.fastly.net/",P="https://{s}.tile.thunderforest.com/",D={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${E}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${E}light_all/{z}/{x}/{y}{r}.png`,dark:`${E}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${T}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${T}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${T}watercolor/{z}/{x}/{y}.png`,terrain:`${T}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${P}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${P}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${P}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${P}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${P}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${P}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${P}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${P}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${P}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${P}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}},O=p("<div>"),A=p=>{let l,c,b;p.id??=d();const[f,v]=m(null),[w,k]=m("undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches||"undefined"!=typeof document&&document.body.classList.contains("dark")),[$,M]=m(!1),[S,j]=m(!1);g((()=>p.onUserInteraction?.($())));const _=(e,t)=>{p.debug&&console.debug("%c[MapGL]","color: #0ea5e9",e,t||"")},z=(e,t)=>{const o=w()&&t?t:e;return"string"==typeof o||o instanceof String?o?.split(":").reduce(((e,t)=>e&&e[t]),C)?.replace("{apikey}",p.apikey||import.meta.env.VITE_VECTOR_API_KEY)||o:o||{version:8,sources:{},layers:[]}};u((async()=>{let e=p.mapLib||await import("mapbox-gl");if(e.Map||(e=window.maplibregl||window.mapboxgl),!e.supported?.())throw new Error("Mapbox GL not supported");_(`Map (v${e.version}) loading...`),l=new e.Map({accessToken:p.options?.accessToken||import.meta.env.VITE_MAPBOX_ACCESS_TOKEN,interactive:p.options?.interactive||!!p.onViewportChange,...p.options,...p.viewport,projection:p.options?.projection,container:c,style:z(p.options?.style,p.darkStyle),fitBoundsOptions:{padding:p.viewport?.padding}}),l.mapLib=e,l.debug=p.debug,l.sourceIdList=[],l.layerIdList=[],l.once("load",(()=>{v(l),_("Map loaded"),["mousedown","touchstart","wheel"].forEach((e=>l.on(e,(e=>!e.rotate&&M(!0))))),["moveend","mouseup","touchend"].forEach((e=>l.on(e,(e=>!e.rotate&&M(!1)))));const e="undefined"!=typeof window&&window?.matchMedia("(prefers-color-scheme: dark)");e?.addEventListener("change",(()=>{k(e.matches),_("Set dark theme to:",e.matches?.toString())})),b=new MutationObserver((()=>{const e=document.body.classList.contains("dark");k(e),_("Set theme to:",e)})),b.observe(document.body,{attributes:!0}),x.forEach((e=>{const t=p[e];let o=!0;if(t){const a=e.slice(2).toLowerCase();"function"==typeof t?l.on(a,(e=>{t(e),o&&_(`Map '${a}' event:`,e),o=!1})):Object.keys(t).forEach((e=>{l.on(a,e,(r=>{t[e](r),o&&_(`Map '${a}' event on '${e}':`,r),o=!1}))}))}})),l.on("move",(e=>{const t={...p.viewport,id:p.id,center:p.viewport?.center?.lat?l.getCenter():[l.getCenter().lng,l.getCenter().lat],zoom:l.getZoom(),pitch:l.getPitch(),bearing:l.getBearing(),inTransit:!0};j(!0),!e.viewport&&p.onViewportChange?.(t)})),l.on("moveend",(e=>{!e.rotate&&p.onViewportChange?.({...p.viewport,inTransit:!1}),j(!1)}))}))})),g(h((()=>p.viewport),(e=>{if(p.id!==e?.id||S())return;const t={...e,...e.bounds?l.cameraForBounds(e.bounds,{padding:e?.padding}):null};l.stop()[p.transitionType||"flyTo"](t),_(`Update Viewport (${p.transitionType||"flyTo"}):`,t)}),{defer:!0})),g((()=>{const e=p.options?.projection;l&&e&&(l.setProjection(e),_("Set Projection to:",e))})),g((()=>{const e=p.cursorStyle;l&&e&&(l.getCanvas().style.cursor=e,_("Set Cursor to:",e))}));return g((e=>{const t=z(p.options?.style,p.darkStyle);if(l?.isStyleLoaded()&&e!==t){const e=l.getStyle(),o=e.layers.filter((e=>l.layerIdList.includes(e.id))),a=Object.keys(e.sources).filter((e=>l.sourceIdList.includes(e))).reduce(((t,o)=>({...t,[o]:e.sources[o]})),{});l.setStyle(t),l.once("styledata",(()=>{if(!o)return;const r=l.getStyle();var n,i;l.setStyle({...r,sources:{...r.sources,...a},layers:(n=r.layers,i=o,i.forEach((e=>{const t=n.findIndex((t=>e.metadata.smg.beforeType?t.type===e.metadata.smg.beforeType:t.id===e.metadata.smg.beforeId));n=-1===t?[...n,e]:[...n.slice(0,t),e,...n.slice(t+1)]})),n),fog:e.fog,terrain:e.terrain}),_("Set Mapstyle to:",t)}))}return t}),p.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach((e=>{g((()=>{const t=p[e];l&&t&&(l[e]=t,_(`Set ${e} to:`,t))}))})),y((()=>{b?.disconnect(),l?.remove(),_("Map removed")})),[(()=>{const e=O();return"function"==typeof c?t(c,e):c=e,o((t=>{const o=p.id,s=p?.class,l=p?.classList,c=p?.class||p?.classList?null:p.style||{position:"absolute",inset:0,"z-index":-1};return o!==t._v$&&a(e,"id",t._v$=o),s!==t._v$2&&r(e,t._v$2=s),t._v$3=n(e,l,t._v$3),t._v$4=i(e,c,t._v$4),t}),{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),e})(),s((()=>{const t=s((()=>!!f()));return()=>t()&&e(L,{get map(){return f()},get children(){return p.children}})})())]},R=l(),V=()=>c(R),q=t=>{const[o]=$();t.id??=d();const a=(e,t)=>{o.map.debug&&console.debug("%c[MapGL]","color: #ec4899",e,t||"")},r=e=>{const o=e?.split(":").reduce(((e,t)=>e&&e[t]),D),a=o?{...t.source,url:"",tiles:[o.replace("{apikey}",t.source.apikey||import.meta.env.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:D[e.split(":")[0]]._copy}:t.source;return a.tiles&&(a.tiles=["a","b","c"].map((e=>a.tiles[0].replace("{s}",e)))),a};o.map.addSource(t.id,r(t.source.url)),o.map.sourceIdList.push(t.id),a("Add Source:",t.id);const n=o.map.getSource(t.id);switch(t.source.type){case"geojson":g((()=>{const e=t.source.data;o.map.isSourceLoaded(t.id)&&(n.setData(e||{}),a("Update GeoJSON Data:",t.id))}));break;case"image":g((()=>{const e=t.source.url,r=t.source.coordinates;o.map.isSourceLoaded(t.id)&&(n.updateImage(e,r),a("Update Image Data:",t.id))}));break;case"vector":g((()=>{const e=t.source.url,r=t.source.tiles;o.map.isSourceLoaded(t.id)&&(e?n.setUrl(e):n.setTiles(r),a("Update Vector Data:",t.id))}));break;case"raster":g((()=>{const e=r(t.source.url);o.map.isSourceLoaded(t.id)&&(e.url?n.setUrl(e.url):n.setTiles(e.tiles),a("Update Raster Data:",t.id))}))}return y((()=>{o.map?.getStyle().layers.forEach((e=>e.source===t.id&&o.map.removeLayer(e.id))),o.map?.getSource(t.id)&&o.map?.removeSource(t.id),a("Remove Source:",t.id)})),e(R.Provider,{get value(){return t.id},get children(){return t.children}})},U=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce(((o,a)=>{const r=e[a];return r!==t[a]&&o.push([a,r]),o}),[]),F=e=>{const[t]=$(),o=e.style?.source||V();e.id??=d();const a=(e,o)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",e,o||"")};return t.map.addLayer(e.customLayer||{...e.style,id:e.id,source:o,metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},e.beforeType?t.map.getStyle().layers.find((t=>t.type===e.beforeType))?.id:e.beforeId),t.map.layerIdList.push(e.id),a("Add Layer:",e.id),M.forEach((o=>{if(e[o]){const r=o.slice(2).toLowerCase();t.map.on(r,e.id,(t=>{e[o](t),a(`Layer '${r}' event on '${e.id}':`,t)}))}})),g((o=>{const r=e.style;if(r!==o)return r.layout!==o?.layout&&U(r.layout,o?.layout).forEach((([o,a])=>t.map.setLayoutProperty(e.id,o,a,{validate:!1}))),r.paint!==o?.paint&&U(r.paint,o?.paint).forEach((([o,a])=>t.map.setPaintProperty(e.id,o,a,{validate:!1}))),r.minzoom===o?.minzoom&&r.maxzoom===o?.maxzoom||t.map.setLayerZoomRange(e.id,r.minzoom,r.maxzoom),r.filter!==o?.filter&&t.map.setFilter(e.id,r.filter,{validate:!1}),a("Update Layer Style:",e.id),r}),e.style),g((o=>{if(e.visible!==o)return t.map.setLayoutProperty(e.id,"visibility",e.visible?"visible":"none",{validate:!1}),a(`Update Visibility (${e.id}):`,e.visible),e.visible}),e.visible),g((async()=>{e.filter&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.setFilter(e.id,e.filter),a(`Update Filter (${e.id}):`,e.filter))})),g((async()=>{e.featureState&&null!==e.featureState.id&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:o,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:o,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state))})),y((()=>t.map?.getLayer(e.id)&&t.map?.removeLayer(e.id))),e.children},Z=e=>{const[t]=$();return g((()=>t.map.setFog(e.style||{}))),y((()=>t.map.setFog(null))),null},G=e=>{const[t]=$();let o=V();return o||e.source||(o=d(),t.map.addSource(o,{type:"raster-dem",url:t.map.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.map.isMapLibre?256:512,maxzoom:t.map.isMapLibre?void 0:14}),t.map.sourceIdList.push(o)),g((()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e.source||o})})),null},B=e=>{const[t]=$(),o=new Map([["navigation",t.map.mapLib.NavigationControl],["scale",t.map.mapLib.ScaleControl],["attribution",t.map.mapLib.AttributionControl],["geolocate",t.map.mapLib.GeolocateControl],["fullscreen",t.map.mapLib.FullscreenControl]]),a=e.custom||o.get(e.type||"navigation");if(!a)throw new Error(`Unknown control type: ${e.type}`);return g((()=>{const o=new a(e.options);o&&t.map.hasControl(o)&&t.map.removeControl(o),t.map.addControl(o,e.position)})),null},W=e=>{const[t]=$();let o=null,a=null;if(!e.lngLat)throw new Error("Marker - lngLat is required");return g((()=>{const r={...e.options},n={...e.options?.popup};if(!t.map)return;const i=t.map.mapLib;b((()=>{a?.remove(),a=e.children?new i.Popup(n).setHTML(e.children).on("close",(()=>e.onClose?.())):null,o?.remove(),o=new i.Marker(r).setPopup(a).on("dragstart",(()=>e.onDragStart?.())).on("dragend",(()=>e.onDragEnd?.())).on("drag",(()=>e.onLngLatChange?.(o.getLngLat().toArray()))).setDraggable(e.draggable||e.options?.draggable).setLngLat(e.lngLat).addTo(t.map),e.openPopup!==a?.isOpen()&&o.togglePopup()}))})),g((()=>e.openPopup!==a?.isOpen()&&o.togglePopup())),g((()=>o.setLngLat(e.lngLat))),g((()=>a?.setHTML(e.children))),g((()=>o.setDraggable(e.draggable))),y((()=>o?.remove())),null},H=e=>{const[t]=$();let o=null;if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");return g((()=>{const a={...e.options};if(!t.map)return;const r=t.map.mapLib;b((()=>{o?.remove(),o=new r.Popup(e.trackPointer?{...a,closeOnClick:!1,closeButton:!1}:{focusAfterOpen:!1,...a}).setHTML(e.children||"").setLngLat(e.lngLat).on("close",(()=>e.onClose?.())).addTo(t.map)}))})),g((()=>e.trackPointer?o.trackPointer():o.setLngLat(e.lngLat))),g((()=>o.setHTML(e.children||""))),y((()=>o?.remove())),null},N={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:!0},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:!0}},X=Object.keys(N),K=e=>{const[t]=$(),[o,a]=m({width:0,height:0}),r=(e,o)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",e,o||"")};y((()=>{t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),r("Remove Image:",e.id)})),g((()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern)throw new Error("Image - Image or Pattern is required");const s=e.pattern?{pixelRatio:2,...e.options}:e.options;n(e.source||i(e.pattern),(n=>{const{width:i,height:p}=n;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,n,s),!e.pattern&&b((()=>i===o().width&&p===o().height))?(t.map.updateImage(e.id,n),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,n,s)),a({width:i,height:p}),r("Add Image:",e.id),t.map.on("style.load",(()=>{t.map.hasImage(e.id)||(t.map.addImage(e.id,n,s),r("Re-Add Image:",e.id))}))}))}));const n=(o,a)=>{if("string"==typeof o&&o?.trimStart().startsWith("<svg")&&(o=(new DOMParser).parseFromString(o,"image/svg+xml").childNodes[0]),o instanceof SVGElement&&(e.options?.fill&&o.setAttribute("fill",e.options.fill),e.options?.stroke&&o.setAttribute("stroke",e.options.stroke),o=(new XMLSerializer).serializeToString(o)),"string"!=typeof o)return a(o);t.map.loadImage(o,(async(t,r)=>{if(!t)return a(r);{"string"==typeof o&&o?.trimEnd().endsWith(".svg")&&(o=await(await fetch(o)).text(),(o=(new DOMParser).parseFromString(o,"image/svg+xml").childNodes[0]).setAttribute("fill",e.options.fill),o.setAttribute("stroke",e.options.stroke),o.setAttribute("transform",e.options.transform),o=(new XMLSerializer).serializeToString(o));const t=new Image;t.crossOrigin="Anonymous",t.onload=()=>{const e=document.createElement("canvas");e.width=Math.max(t.width,50),e.height=Math.max(t.height,50);const o=e.getContext("2d");return o.imageSmoothingEnabled=!0,o.drawImage(t,0,0,e.width,e.height),a(o.getImageData(0,0,e.width,e.height))},t.src=o.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+o:o}}))},i=e=>{const t=N[e.type];return{width:t.size,height:t.size,data:new Uint8Array(t.size*t.size*4),onAdd:function(){let e=document.createElement("canvas");e.width=e.height=t.size,this.ctx=e.getContext("2d",{willReadFrequently:!0})},render:function(){return this.ctx.fillStyle=e.background||"transparent",this.ctx.fillRect(0,0,this.width,this.height),this.ctx.strokeStyle=this.ctx.fillStyle=e.color||"black",this.ctx.lineWidth=e.lineWith||1,this.ctx.stroke(new Path2D(t.path)),t.fill&&this.ctx.fill(new Path2D(t.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,!0}}};return null},Y={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},J=e=>{const[t]=$();if(!t.map)return null;let o=.1,a=!1;const r=()=>{e.translate&&window.requestAnimationFrame(r);const n=[e.translate.start,e.translate.end,e.translate.easing?Y[e.translate.easing](o):o];(async([e,o,a],r)=>{const n=t.map.getFreeCameraOptions();n.position=t.map.mapLib.MercatorCoordinate.fromLngLat([e,o],a),n.lookAtPoint(r),t.map.setFreeCameraOptions(n)})("line"===e.translate.type?((e,t,o)=>e.map(((a,r)=>(1-o)*e[r]+o*t[r])))(...n):((e,t,o)=>{const a=e.map(((o,a)=>e[a]*t[a])).reduce(((e,t)=>e+t)),r=Math.acos(a);return e.map(((a,n)=>Math.sin((1-o)*r)/Math.sin(r)*e[n]+Math.sin(o*r)/Math.sin(r)*t[n]))})(...n),e.translate.target),!e.translate.loop&&(o>1||o<0)&&(a=!a),o=a?o-.001:o+.001};g((()=>{e.translate&&window.requestAnimationFrame(r)}));const n={duration:1e3,easing:e=>e},i=()=>{if(t.userInteraction)return;const{secPerRev:o=120,maxSpinZoom:a=5,slowSpinZoom:r=3}=e.rotateGlobe,i=t.map.getZoom();if(i>a)return;let s=360/o;i>r&&(s*=(a-i)/(a-r));const p=t.map.getCenter();p.lng=e.reverse?p.lng+s:p.lng-s,t.map.easeTo({center:p,...n},{rotate:!0})},s=()=>{if(!e.rotateViewport||t.userInteraction)return;const o=e.rotateViewport,a=o?.secPerRev||60,r=e.reverse?t.map.getBearing()+360/a:t.map.getBearing()-360/a,i=o?.pitch||60,s=o?.around;t.map.easeTo({bearing:r,pitch:i,around:s,...n},{rotate:!0})},p=()=>e.rotateGlobe?i():s();let l;return t.map.on("moveend",p).on("dragend",p),g((()=>{null!=e.rotateGlobe&&(e.rotateGlobe?(l=t.map.getCenter(),i()):e.resetWhenStopped?t.map.stop().easeTo({center:l}):t.map.stop())})),g((()=>{null!=e.rotateViewport&&(e.rotateViewport?s():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop())})),y((()=>t.map.off("moveend",p).off("dragend",p))),e.children},Q=e=>{const[t]=$();return g((()=>t.map.setLight(e.style||{}))),y((()=>t.map?.setLight(null))),null},ee=e=>{const[t]=$(),o=new e.lib(e.options);t.map.addControl(o,e.position||"top-right"),e.getInstance&&e.getInstance(o);const a={};return S.forEach((o=>{if(e[o]){const r=`draw.${o.slice(2).toLowerCase()}`,n=t=>e[o](t);a[r]=n,t.map.on(r,n)}})),y((()=>{Object.keys(a).forEach((e=>t.map.off(e,a[e]))),t.map?.removeControl(o)})),null};export{Z as Atmosphere,J as Camera,B as Control,ee as Draw,K as Image,F as Layer,Q as Light,L as MapProvider,W as Marker,H as Popup,q as Source,G as Terrain,A as default,X as patternList,$ as useMapContext,V as useSourceId};
1
+ import{createComponent as e,use as t,effect as o,setAttribute as a,className as r,classList as n,style as s,memo as i,template as p}from"solid-js/web";import{createContext as l,useContext as c,createUniqueId as d,createSignal as m,onMount as g,createEffect as u,on as h,onCleanup as y,untrack as b}from"solid-js";import{createStore as f}from"solid-js/store";const[v,w]=f({map:null}),k=l([v]),$=()=>c(k),L=t=>(t.map&&w("map",t.map),e(k.Provider,{value:[v],get children(){return t.children}})),x=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onPreClick","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel","onWheel","onResize","onRemove","onTouchMove","onMoveStart","onMove","onMoveEnd","onDragStart","onDrag","onDragEnd","onZoomStart","onZoom","onZoomEnd","onRotateStart","onRotate","onRotatEnd","onPitchStart","onPitch","onPitchEnd","onBoxZoomStart","onBoxZoomEnd","onBoxZoomCancel","onWebglContextLost","onWebglContextRestored","onLoad","onRender","onIdle","onError","onData","onStyleData","onSourceData","onDataLoading","onStyleDataLoading","onSourceDataLoading","onStyleImageMissing"],M=["onMouseDown","onMouseUp","onMouseOver","onMouseOut","onMouseMove","onMouseEnter","onMouseLeave","onClick","onDblClick","onContextMenu","onTouchStart","onTouchEnd","onTouchCancel"],S=["onCreate","onDelete","onCombine","onUncombine","onUpdate","onSelectionchange","onModechange","onRender","onActionable"],j="mapbox://styles/mapbox",_="https://raw.githubusercontent.com/",z="https://raw.githubusercontent.com/GIShub4/map-styles/main/",C="https://assets.vector.hereapi.com/styles/",E={mb:{light:`${j}/light-v11`,dark:`${j}/dark-v11`,street:`${j}/streets-v12`,outdoor:`${j}/outdoors-v12`,sat:`${j}/satellite-v9`,sat_street:`${j}/satellite-streets-v12`,nav:`${j}/navigation-guidance-day-v4`,nav_night:`${j}/navigation-guidance-night-v4`,basic:`${j}/cjf4m44iw0uza2spb3q0a7s41`,monochrome:`${j}/cjv6rzz4j3m4b1fqcchuxclhb`,leshine:`${j}/cjcunv5ae262f2sm9tfwg8i0w`,icecream:`${j}/cj7t3i5yj0unt2rmt3y4b5e32`,cali:`${j}/cjerxnqt3cgvp2rmyuxbeqme7`,northstar:`${j}/cj44mfrt20f082snokim4ungi`,mineral:`${j}/cjtep62gq54l21frr1whf27ak`,moonlight:`${j}/cj3kbeqzo00022smj7akz3o1e`,frank:`${j}-map-design/ckshxkppe0gge18nz20i0nrwq`,minimo:`${j}-map-design/cksjc2nsq1bg117pnekb655h1`,decimal:`${j}-map-design/ck4014y110wt61ctt07egsel6`,standard:`${j}-map-design/ckr0svm3922ki18qntevm857n`,blueprint:`${j}-map-design/cks97e1e37nsd17nzg7p0308g`,bubble:`${j}-map-design/cksysy2nl62zp17quosctdtcc`,pencil:`${j}-map-design/cks9iema71es417mlrft4go2k`,swiss_ski:`${_}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,vintage:`${_}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,whaam:`${_}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,neon:`${_}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,camoflauge:`${_}jingsam/mapbox-gl-styles/master/Camouflage.json`,emerald:`${_}jingsam/mapbox-gl-styles/master/Emerald.json`,runner:`${_}jingsam/mapbox-gl-styles/master/Runner.json`,x_ray:`${_}jingsam/mapbox-gl-styles/master/X-ray.json`},here:{base:`${C}berlin/base/mapbox/tilezen?apikey={apikey}`,day:`${C}berlin/day/mapbox/tilezen?apikey={apikey}`,night:`${C}berlin/night/mapbox/tilezen?apikey={apikey}`},esri:{blueprint:`${z}esri:blueprint.json`,charted_territory:`${z}esri:charted-territory.json`,colored_pencil:`${z}esri:colored-pencil.json`,community:`${z}esri:community.json`,mid_century:`${z}esri:mid-century.json`,modern_antique:`${z}esri:modern-antique.json`,nat_geo:`${z}esri:national-geographic.json`,newspaper:`${z}esri:newspaper.json`,open_street_map:`${z}esri:open-street-map.json`,light_gray_canvas:`${z}esri:light-gray-canvas.json`,dark_gray_canvas:`${z}esri:dark-gray-canvas.json`,human_geo_light:`${z}esri:human-geography-light.json`,human_geo_dark:`${z}esri:human-geography-dark.json`,world_navigation:`${z}esri:world-navigation.json`,world_street:`${z}esri:world-street.json`,world_street_night:`${z}esri:world-street-night.json`,world_terrain:`${z}esri:world-terrain.json`,world_terrain_hybrid:`${z}esri:world-terrain-hybrid.json`,world_topographic:`${z}esri:world-topographic.json`,chromium:`${z}esri:chromium.json`,dreamcatcher:`${z}esri:dreamcatcher.json`,seahaven:`${z}esri:seahaven.json`,sangria:`${z}esri:sangria.json`,mercurial:`${z}esri:mercurial.json`,imagery:`${z}esri:imagery.json`,imagery_hybrid:`${z}esri:imagery-hybrid.json`,firefly:`${z}esri:firefly.json`,firefly_hybrid:`${z}esri:firefly-hybrid.json`,oceans:`${z}esri:oceans.json`}},I="https://{s}.basemaps.cartocdn.com/rastertiles/",T="https://stamen-tiles-{s}.a.ssl.fastly.net/",P="https://{s}.tile.thunderforest.com/",D={osm:{org:"https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png",human:"https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png",cycle:"https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png",topo:"https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png",_copy:'<a href="https://www.openstreetmap.org/copyright" target="_blank">&copy; OpenStreetMap</a>'},carto:{voyager:`${I}voyager_labels_under/{z}/{x}/{y}{r}.png`,positron:`${I}light_all/{z}/{x}/{y}{r}.png`,dark:`${I}dark_all/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://carto.com/attribution" target="_blank">&copy; Carto</a>'},stamen:{toner:`${T}toner/{z}/{x}/{y}{r}.png`,toner_lite:`${T}toner-lite/{z}/{x}/{y}{r}.png`,watercolor:`${T}watercolor/{z}/{x}/{y}.png`,terrain:`${T}terrain/{z}/{x}/{y}{r}.png`,_copy:'<a href="https://stamen.com/privacy-policy" target="_blank">&copy; Stamen Design</a>'},tf:{cycle:`${P}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans:`${P}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,trans_dark:`${P}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,landscape:`${P}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,outdoors:`${P}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,neighbourhood:`${P}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,spinal:`${P}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,pioneer:`${P}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,atlas:`${P}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,mobile:`${P}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,_copy:'<a href="https://thunderforest.com/privacy" target="_blank">&copy; Thunderforest</a>'}},O=p("<div>"),A=p=>{let l,c,b;p.id??=d();const[f,v]=m(null),[w,k]=m("undefined"!=typeof window&&window.matchMedia("(prefers-color-scheme: dark)").matches||"undefined"!=typeof document&&document.body.classList.contains("dark")),[$,M]=m(!1),S=(e,t)=>{p.debug&&console.debug("%c[MapGL]","color: #0ea5e9",e,t||"")},j=(e,t)=>{const o=w()&&t?t:e;return"string"==typeof o||o instanceof String?o?.split(":").reduce(((e,t)=>e&&e[t]),E)?.replace("{apikey}",p.apikey||import.meta.env.VITE_VECTOR_API_KEY)||o:o||{version:8,sources:{},layers:[]}};g((async()=>{let e=p.mapLib||await import("mapbox-gl");if(e.Map||(e=window.maplibregl||window.mapboxgl),!e.supported?.())throw new Error("Mapbox GL not supported");S(`Map (v${e.version}) loading...`),l=new e.Map({accessToken:p.options?.accessToken||import.meta.env.VITE_MAPBOX_ACCESS_TOKEN,interactive:p.options?.interactive||!!p.onViewportChange,...p.options,...p.viewport,projection:p.options?.projection,container:c,style:j(p.options?.style,p.darkStyle),fitBoundsOptions:{padding:p.viewport?.padding}}),l.mapLib=e,l.debug=p.debug,l.sourceIdList=[],l.layerIdList=[],l.once("load",(()=>{v(l),S("Map loaded"),["mousedown","touchstart","wheel"].forEach((e=>l.on(e,(e=>!e.rotate&&p.onUserInteraction(!0))))),["moveend","mouseup","touchend"].forEach((e=>l.on(e,(e=>!e.rotate&&p.onUserInteraction(!1)))));const e="undefined"!=typeof window&&window?.matchMedia("(prefers-color-scheme: dark)");e?.addEventListener("change",(()=>{k(e.matches),S("Set dark theme to:",e.matches?.toString())})),b=new MutationObserver((()=>{const e=document.body.classList.contains("dark");k(e),S("Set theme to:",e)})),b.observe(document.body,{attributes:!0}),x.forEach((e=>{const t=p[e];let o=!0;if(t){const a=e.slice(2).toLowerCase();"function"==typeof t?l.on(a,(e=>{t(e),o&&S(`Map '${a}' event:`,e),o=!1})):Object.keys(t).forEach((e=>{l.on(a,e,(r=>{t[e](r),o&&S(`Map '${a}' event on '${e}':`,r),o=!1}))}))}})),l.on("move",(e=>{const t={...p.viewport,id:p.id,center:p.viewport?.center?.lat?l.getCenter():[l.getCenter().lng,l.getCenter().lat],zoom:l.getZoom(),pitch:l.getPitch(),bearing:l.getBearing(),inTransit:!0};M(!0),!e.viewport&&p.onViewportChange?.(t)})),l.on("moveend",(e=>{!e.rotate&&p.onViewportChange?.({...p.viewport,inTransit:!1}),M(!1)}))}))})),u(h((()=>p.viewport),(e=>{if(p.id!==e?.id||$())return;const t={...e,...e.bounds?l.cameraForBounds(e.bounds,{padding:e?.padding}):null};l.stop()[p.transitionType||"flyTo"](t),S(`Update Viewport (${p.transitionType||"flyTo"}):`,t)}),{defer:!0})),u((()=>{const e=p.options?.projection;l&&e&&(l.setProjection(e),S("Set Projection to:",e))})),u((()=>{const e=p.cursorStyle;l&&e&&(l.getCanvas().style.cursor=e,S("Set Cursor to:",e))}));return u((e=>{const t=j(p.options?.style,p.darkStyle);if(l?.isStyleLoaded()&&e!==t){const e=l.getStyle(),o=e.layers.filter((e=>l.layerIdList.includes(e.id))),a=Object.keys(e.sources).filter((e=>l.sourceIdList.includes(e))).reduce(((t,o)=>({...t,[o]:e.sources[o]})),{});l.setStyle(t),l.once("styledata",(()=>{if(!o)return;const r=l.getStyle();var n,s;l.setStyle({...r,sources:{...r.sources,...a},layers:(n=r.layers,s=o,s.forEach((e=>{const t=n.findIndex((t=>e.metadata.smg.beforeType?t.type===e.metadata.smg.beforeType:t.id===e.metadata.smg.beforeId));n=-1===t?[...n,e]:[...n.slice(0,t),e,...n.slice(t+1)]})),n),fog:e.fog,terrain:e.terrain}),S("Set Mapstyle to:",t)}))}return t}),p.options?.style),["showTileBoundaries","showTerrainWireframe","showCollisionBoxes","showPadding","showOverdrawInspector"].forEach((e=>{u((()=>{const t=p[e];l&&t&&(l[e]=t,S(`Set ${e} to:`,t))}))})),y((()=>{b?.disconnect(),l?.remove(),S("Map removed")})),[(()=>{const e=O();return"function"==typeof c?t(c,e):c=e,o((t=>{const o=p.id,i=p?.class,l=p?.classList,c=p?.class||p?.classList?null:p.style||{position:"absolute",inset:0,"z-index":-1};return o!==t._v$&&a(e,"id",t._v$=o),i!==t._v$2&&r(e,t._v$2=i),t._v$3=n(e,l,t._v$3),t._v$4=s(e,c,t._v$4),t}),{_v$:void 0,_v$2:void 0,_v$3:void 0,_v$4:void 0}),e})(),i((()=>{const t=i((()=>!!f()));return()=>t()&&e(L,{get map(){return f()},get children(){return p.children}})})())]},R=l(),V=()=>c(R),q=t=>{const[o]=$();t.id??=d();const a=(e,t)=>{o.map.debug&&console.debug("%c[MapGL]","color: #ec4899",e,t||"")},r=e=>{const o=e?.split(":").reduce(((e,t)=>e&&e[t]),D),a=o?{...t.source,url:"",tiles:[o.replace("{apikey}",t.source.apikey||import.meta.env.VITE_RASTER_API_KEY).replace("{r}",window.devicePixelRatio>1?"@2x":"")],attribution:D[e.split(":")[0]]._copy}:t.source;return a.tiles&&(a.tiles=["a","b","c"].map((e=>a.tiles[0].replace("{s}",e)))),a};o.map.addSource(t.id,r(t.source.url)),o.map.sourceIdList.push(t.id),a("Add Source:",t.id);const n=o.map.getSource(t.id);switch(t.source.type){case"geojson":u((()=>{const e=t.source.data;o.map.isSourceLoaded(t.id)&&(n.setData(e||{}),a("Update GeoJSON Data:",t.id))}));break;case"image":u((()=>{const e=t.source.url,r=t.source.coordinates;o.map.isSourceLoaded(t.id)&&(n.updateImage(e,r),a("Update Image Data:",t.id))}));break;case"vector":u((()=>{const e=t.source.url,r=t.source.tiles;o.map.isSourceLoaded(t.id)&&(e?n.setUrl(e):n.setTiles(r),a("Update Vector Data:",t.id))}));break;case"raster":u((()=>{const e=r(t.source.url);o.map.isSourceLoaded(t.id)&&(e.url?n.setUrl(e.url):n.setTiles(e.tiles),a("Update Raster Data:",t.id))}))}return y((()=>{o.map?.getStyle().layers.forEach((e=>e.source===t.id&&o.map.removeLayer(e.id))),o.map?.getSource(t.id)&&o.map?.removeSource(t.id),a("Remove Source:",t.id)})),e(R.Provider,{get value(){return t.id},get children(){return t.children}})},U=(e={},t={})=>[...new Set([...Object.keys(e),...Object.keys(t)])].reduce(((o,a)=>{const r=e[a];return r!==t[a]&&o.push([a,r]),o}),[]),F=e=>{const[t]=$(),o=e.style?.source||V();e.id??=d();const a=(e,o)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",e,o||"")};return t.map.addLayer(e.customLayer||{...e.style,id:e.id,source:o,metadata:{smg:{beforeType:e.beforeType,beforeId:e.beforeId}}},e.beforeType?t.map.getStyle().layers.find((t=>t.type===e.beforeType))?.id:e.beforeId),t.map.layerIdList.push(e.id),a("Add Layer:",e.id),M.forEach((o=>{if(e[o]){const r=o.slice(2).toLowerCase();t.map.on(r,e.id,(t=>{e[o](t),a(`Layer '${r}' event on '${e.id}':`,t)}))}})),u((o=>{const r=e.style;if(r!==o)return r.layout!==o?.layout&&U(r.layout,o?.layout).forEach((([o,a])=>t.map.setLayoutProperty(e.id,o,a,{validate:!1}))),r.paint!==o?.paint&&U(r.paint,o?.paint).forEach((([o,a])=>t.map.setPaintProperty(e.id,o,a,{validate:!1}))),r.minzoom===o?.minzoom&&r.maxzoom===o?.maxzoom||t.map.setLayerZoomRange(e.id,r.minzoom,r.maxzoom),r.filter!==o?.filter&&t.map.setFilter(e.id,r.filter,{validate:!1}),a("Update Layer Style:",e.id),r}),e.style),u((o=>{if(e.visible!==o)return t.map.setLayoutProperty(e.id,"visibility",e.visible?"visible":"none",{validate:!1}),a(`Update Visibility (${e.id}):`,e.visible),e.visible}),e.visible),u((async()=>{e.filter&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.setFilter(e.id,e.filter),a(`Update Filter (${e.id}):`,e.filter))})),u((async()=>{e.featureState&&null!==e.featureState.id&&(!t.map.isStyleLoaded()&&await t.map.once("styledata"),t.map.removeFeatureState({source:o,sourceLayer:e.style["source-layer"]}),t.map.setFeatureState({source:o,sourceLayer:e.style["source-layer"],id:e.featureState.id},e.featureState.state))})),y((()=>t.map?.getLayer(e.id)&&t.map?.removeLayer(e.id))),e.children},Z=e=>{const[t]=$();return u((()=>t.map.setFog(e.style||{}))),y((()=>t.map.setFog(null))),null},G=e=>{const[t]=$();let o=V();return o||e.source||(o=d(),t.map.addSource(o,{type:"raster-dem",url:t.map.isMapLibre?"https://demotiles.maplibre.org/terrain-tiles/tiles.json":"mapbox://mapbox.terrain-rgb",tileSize:t.map.isMapLibre?256:512,maxzoom:t.map.isMapLibre?void 0:14}),t.map.sourceIdList.push(o)),u((()=>{t.map.setTerrain({exaggeration:e.exaggeration||1,source:e.source||o})})),null},B=e=>{const[t]=$(),o=new Map([["navigation",t.map.mapLib.NavigationControl],["scale",t.map.mapLib.ScaleControl],["attribution",t.map.mapLib.AttributionControl],["geolocate",t.map.mapLib.GeolocateControl],["fullscreen",t.map.mapLib.FullscreenControl]]),a=e.custom||o.get(e.type||"navigation");if(!a)throw new Error(`Unknown control type: ${e.type}`);return u((()=>{const o=new a(e.options);o&&t.map.hasControl(o)&&t.map.removeControl(o),t.map.addControl(o,e.position)})),null},W=e=>{const[t]=$();let o=null,a=null;if(!e.lngLat)throw new Error("Marker - lngLat is required");return u((()=>{const r={...e.options},n={...e.options?.popup};if(!t.map)return;const s=t.map.mapLib;b((()=>{a?.remove(),a=e.children?new s.Popup(n).setHTML(e.children).on("close",(()=>e.onClose?.())):null,o?.remove(),o=new s.Marker(r).setPopup(a).on("dragstart",(()=>e.onDragStart?.())).on("dragend",(()=>e.onDragEnd?.())).on("drag",(()=>e.onLngLatChange?.(o.getLngLat().toArray()))).setDraggable(e.draggable||e.options?.draggable).setLngLat(e.lngLat).addTo(t.map),e.openPopup!==a?.isOpen()&&o.togglePopup()}))})),u((()=>e.openPopup!==a?.isOpen()&&o.togglePopup())),u((()=>o.setLngLat(e.lngLat))),u((()=>a?.setHTML(e.children))),u((()=>o.setDraggable(e.draggable))),y((()=>o?.remove())),null},H=e=>{const[t]=$();let o=null;if(!e.trackPointer&&!e.lngLat)throw new Error("Popup - lngLat or trackPointer is required");return u((()=>{const a={...e.options};if(!t.map)return;const r=t.map.mapLib;b((()=>{o?.remove(),o=new r.Popup(e.trackPointer?{...a,closeOnClick:!1,closeButton:!1}:{focusAfterOpen:!1,...a}).setHTML(e.children||"").setLngLat(e.lngLat).on("close",(()=>e.onClose?.())).addTo(t.map)}))})),u((()=>e.trackPointer?o.trackPointer():o.setLngLat(e.lngLat))),u((()=>o.setHTML(e.children||""))),y((()=>o?.remove())),null},N={diagonal_l:{size:20,path:"M20 0 0 20M-10 10 10-10M10 30 30 10"},diagonal_r:{size:20,path:"M0 0 20 20M30 10 10-10M10 30-10 10"},horizontal:{size:14,path:"M7 0V20"},vertical:{size:14,path:"M0 7H20"},cross:{size:18,path:"M9 0V18M0 9H18"},hash:{size:30,path:"M15 0 30 15 15 30 0 15Z"},chevron_h:{size:20,path:"M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30"},chevron_v:{size:20,path:"M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5"},square:{size:20,path:"M8 8H12V12H8Z",fill:!0},hex:{size:50,path:"M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50"},circle:{size:25,path:"M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15",fill:!0}},X=Object.keys(N),K=e=>{const[t]=$(),[o,a]=m({width:0,height:0}),r=(e,o)=>{t.map.debug&&console.debug("%c[MapGL]","color: #10b981",e,o||"")};y((()=>{t.map?.hasImage(e.id)&&t.map?.removeImage(e.id),r("Remove Image:",e.id)})),u((()=>{if(!e.id)throw new Error("Image - ID is required");if(!e.source&&!e.pattern)throw new Error("Image - Image or Pattern is required");const i=e.pattern?{pixelRatio:2,...e.options}:e.options;n(e.source||s(e.pattern),(n=>{const{width:s,height:p}=n;t.map&&!t.map.hasImage(e.id)&&t.map.addImage(e.id,n,i),!e.pattern&&b((()=>s===o().width&&p===o().height))?(t.map.updateImage(e.id,n),t.map.triggerRepaint()):(t.map.removeImage(e.id),t.map.addImage(e.id,n,i)),a({width:s,height:p}),r("Add Image:",e.id),t.map.on("style.load",(()=>{t.map.hasImage(e.id)||(t.map.addImage(e.id,n,i),r("Re-Add Image:",e.id))}))}))}));const n=(o,a)=>{if("string"==typeof o&&o?.trimStart().startsWith("<svg")&&(o=(new DOMParser).parseFromString(o,"image/svg+xml").childNodes[0]),o instanceof SVGElement&&(e.options?.fill&&o.setAttribute("fill",e.options.fill),e.options?.stroke&&o.setAttribute("stroke",e.options.stroke),o=(new XMLSerializer).serializeToString(o)),"string"!=typeof o)return a(o);t.map.loadImage(o,(async(t,r)=>{if(!t)return a(r);{"string"==typeof o&&o?.trimEnd().endsWith(".svg")&&(o=await(await fetch(o)).text(),(o=(new DOMParser).parseFromString(o,"image/svg+xml").childNodes[0]).setAttribute("fill",e.options.fill),o.setAttribute("stroke",e.options.stroke),o.setAttribute("transform",e.options.transform),o=(new XMLSerializer).serializeToString(o));const t=new Image;t.crossOrigin="Anonymous",t.onload=()=>{const e=document.createElement("canvas");e.width=Math.max(t.width,50),e.height=Math.max(t.height,50);const o=e.getContext("2d");return o.imageSmoothingEnabled=!0,o.drawImage(t,0,0,e.width,e.height),a(o.getImageData(0,0,e.width,e.height))},t.src=o.trimStart().startsWith("<svg")?"data:image/svg+xml;charset=utf-8,"+o:o}}))},s=e=>{const t=N[e.type];return{width:t.size,height:t.size,data:new Uint8Array(t.size*t.size*4),onAdd:function(){let e=document.createElement("canvas");e.width=e.height=t.size,this.ctx=e.getContext("2d",{willReadFrequently:!0})},render:function(){return this.ctx.fillStyle=e.background||"transparent",this.ctx.fillRect(0,0,this.width,this.height),this.ctx.strokeStyle=this.ctx.fillStyle=e.color||"black",this.ctx.lineWidth=e.lineWith||1,this.ctx.stroke(new Path2D(t.path)),t.fill&&this.ctx.fill(new Path2D(t.path)),this.data=this.ctx.getImageData(0,0,this.width,this.height).data,!0}}};return null},Y={in:e=>e*e,out:e=>1-(1-e)*(1-e),inOut:e=>e<.5?2*e*e:1-Math.pow(-2*e+2,2)/2},J=e=>{const[t]=$();let o=.1,a=!1;const[r,n]=m(!1);["mousedown","touchstart","wheel"].forEach((e=>t.map.on(e,(e=>!e.rotate&&n(!0))))),["moveend","mouseup","touchend"].forEach((e=>t.map.on(e,(e=>!e.rotate&&n(!1)))));const s=()=>{e.translate&&window.requestAnimationFrame(s);const r=[e.translate.start,e.translate.end,e.translate.easing?Y[e.translate.easing](o):o];(async([e,o,a],r)=>{const n=t.map.getFreeCameraOptions();n.position=t.map.mapLib.MercatorCoordinate.fromLngLat([e,o],a),n.lookAtPoint(r),t.map.setFreeCameraOptions(n)})("line"===e.translate.type?((e,t,o)=>e.map(((a,r)=>(1-o)*e[r]+o*t[r])))(...r):((e,t,o)=>{const a=e.map(((o,a)=>e[a]*t[a])).reduce(((e,t)=>e+t)),r=Math.acos(a);return e.map(((a,n)=>Math.sin((1-o)*r)/Math.sin(r)*e[n]+Math.sin(o*r)/Math.sin(r)*t[n]))})(...r),e.translate.target),!e.translate.loop&&(o>1||o<0)&&(a=!a),o=a?o-.001:o+.001};u((()=>{e.translate&&window.requestAnimationFrame(s)}));const i={duration:1e3,easing:e=>e},p=()=>{if(r())return;const{secPerRev:o=120,maxSpinZoom:a=5,slowSpinZoom:n=3}=e.rotateGlobe,s=t.map.getZoom();if(s>a)return;let p=360/o;s>n&&(p*=(a-s)/(a-n));const l=t.map.getCenter();l.lng=e.reverse?l.lng+p:l.lng-p,t.map.easeTo({center:l,...i},{rotate:!0})},l=()=>{if(!e.rotateViewport||r())return;const o=e.rotateViewport,a=o?.secPerRev||60,n=e.reverse?t.map.getBearing()+360/a:t.map.getBearing()-360/a,s=o?.pitch||60,p=o?.around;t.map.easeTo({bearing:n,pitch:s,around:p,...i},{rotate:!0})},c=()=>e.rotateGlobe?p():l();let d;return t.map.on("moveend",c).on("dragend",c),u((()=>{null!=e.rotateGlobe&&(e.rotateGlobe?(d=t.map.getCenter(),p()):e.resetWhenStopped?t.map.stop().easeTo({center:d}):t.map.stop())})),u((()=>{null!=e.rotateViewport&&(e.rotateViewport?l():e.resetWhenStopped?t.map.stop().resetNorthPitch():t.map.stop())})),y((()=>t.map.off("moveend",c).off("dragend",c))),e.children},Q=e=>{const[t]=$();return u((()=>t.map.setLight(e.style||{}))),y((()=>t.map?.setLight(null))),null},ee=e=>{const[t]=$(),o=new e.lib(e.options);t.map.addControl(o,e.position||"top-right"),e.getInstance&&e.getInstance(o);const a={};return S.forEach((o=>{if(e[o]){const r=`draw.${o.slice(2).toLowerCase()}`,n=t=>e[o](t);a[r]=n,t.map.on(r,n)}})),y((()=>{Object.keys(a).forEach((e=>t.map.off(e,a[e]))),t.map?.removeControl(o)})),null};export{Z as Atmosphere,J as Camera,B as Control,ee as Draw,K as Image,F as Layer,Q as Light,L as MapProvider,W as Marker,H as Popup,q as Source,G as Terrain,A as default,X as patternList,$ as useMapContext,V as useSourceId};
2
2
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":["../../src/components/MapProvider/index.tsx","../../src/events.ts","../../src/mapStyles.ts","../../src/components/MapGL/index.tsx","../../src/components/Source/index.tsx","../../src/components/Layer/index.tsx","../../src/components/Atmosphere/index.tsx","../../src/components/Terrain/index.tsx","../../src/components/Control/index.tsx","../../src/components/Marker/index.tsx","../../src/components/Popup/index.tsx","../../src/components/Image/index.tsx","../../src/components/Camera/index.tsx","../../src/components/Light/index.tsx","../../src/components/Draw/index.tsx"],"sourcesContent":["import { createContext, useContext, ParentComponent } from \"solid-js\";\nimport { createStore } from \"solid-js/store\";\nimport type { Map } from '../MapGL'\n\nconst [state, setState] = createStore({\n map: null,\n userInteraction: false\n})\n\nexport const MapContext = createContext([state])\n\nexport const useMapContext = () => useContext(MapContext)\n\nexport const MapProvider: ParentComponent<{\n map?: Map,\n userInteraction?: boolean;\n}> = props => {\n props.map && setState('map', props.map)\n props.userInteraction && setState('userInteraction', props.userInteraction)\n\n return (\n <MapContext.Provider value={[state]}>\n {props.children}\n </MapContext.Provider>\n )\n}","import type {\n MapMouseEvent,\n MapTouchEvent,\n MapWheelEvent,\n MapDataEvent,\n MapBoxZoomEvent,\n} from 'mapbox-gl'\n\ntype mapEventTypes = {\n onMouseDown?: (event: MapMouseEvent) => void\n onMouseUp?: (event: MapMouseEvent) => void\n onMouseOver?: (event: MapMouseEvent) => void\n onMouseOut?: (event: MapMouseEvent) => void\n onMouseMove?: (event: MapMouseEvent) => void\n onMouseEnter?: (event: MapMouseEvent) => void\n onMouseLeave?: (event: MapMouseEvent) => void\n onPreClick?: (event: MapMouseEvent) => void\n onClick?: (event: MapMouseEvent) => void\n onDblClick?: (event: MapMouseEvent) => void\n onContextMenu?: (event: MapMouseEvent) => void\n onTouchStart?: (event: MapTouchEvent) => void\n onTouchEnd?: (event: MapTouchEvent) => void\n onTouchCancel?: (event: MapTouchEvent) => void\n onTouchMove?: (event: MapTouchEvent) => void\n onWheel?: (event: MapWheelEvent) => void\n onResize?: () => void\n onRemove?: () => void\n onMoveStart?: (event: DragEvent) => void\n onMove?: (event: MapMouseEvent | MapTouchEvent) => void\n onMoveEnd?: (event: DragEvent) => void\n onDragStart?: (event: DragEvent) => void\n onDrag?: (event: MapMouseEvent | MapTouchEvent) => void\n onDragEnd?: (event: DragEvent) => void\n onZoomStart?: (event: MapMouseEvent | MapTouchEvent) => void\n onZoom?: (event: MapMouseEvent | MapTouchEvent) => void\n onZoomEnd?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotateStart?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotate?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotatEnd?: (event: MapMouseEvent | MapTouchEvent) => void\n onPitchStart?: (event: MapDataEvent) => void\n onPitch?: (event: MapDataEvent) => void\n onPitchEnd?: (event: MapDataEvent) => void\n onBoxZoomStart?: (event: MapBoxZoomEvent) => void\n onBoxZoomEnd?: (event: MapBoxZoomEvent) => void\n onBoxZoomCancel?: (event: MapBoxZoomEvent) => void\n onWebglContextLost?: () => void\n onWebglContextRestored?: () => void\n onLoad?: (event: any) => void\n onRender?: () => void\n onIdle?: () => void\n onError?: (error: string) => void\n onData?: (event: MapDataEvent) => void\n onStyleData?: (event: MapDataEvent) => void\n onSourceData?: (event: MapDataEvent) => void\n onDataLoading?: (event: MapDataEvent) => void\n onStyleDataLoading?: (event: MapDataEvent) => void\n onSourceDataLoading?: (event: MapDataEvent) => void\n onStyleImageMissing?: (event: MapDataEvent) => void\n}\n\nconst mapEvents: string[] = [\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseOver',\n 'onMouseOut',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onPreClick',\n 'onClick',\n 'onDblClick',\n 'onContextMenu',\n 'onTouchStart',\n 'onTouchEnd',\n 'onTouchCancel',\n 'onWheel',\n 'onResize',\n 'onRemove',\n 'onTouchMove',\n 'onMoveStart',\n 'onMove',\n 'onMoveEnd',\n 'onDragStart',\n 'onDrag',\n 'onDragEnd',\n 'onZoomStart',\n 'onZoom',\n 'onZoomEnd',\n 'onRotateStart',\n 'onRotate',\n 'onRotatEnd',\n 'onPitchStart',\n 'onPitch',\n 'onPitchEnd',\n 'onBoxZoomStart',\n 'onBoxZoomEnd',\n 'onBoxZoomCancel',\n 'onWebglContextLost',\n 'onWebglContextRestored',\n 'onLoad',\n 'onRender',\n 'onIdle',\n 'onError',\n 'onData',\n 'onStyleData',\n 'onSourceData',\n 'onDataLoading',\n 'onStyleDataLoading',\n 'onSourceDataLoading',\n 'onStyleImageMissing',\n]\n\ntype layerEventTypes = {\n onMouseDown?: (event: MapMouseEvent) => void\n /** called when the mouse button is pressed down on the layer */\n onMouseUp?: (event: MapMouseEvent) => void\n /** called when the mouse button is released after a mouse down event on the layer */\n onMouseOver?: (event: MapMouseEvent) => void\n /** called when the mouse enters the layer */\n onMouseOut?: (event: MapMouseEvent) => void\n /** called when the mouse leaves the layer */\n onMouseMove?: (event: MapMouseEvent) => void\n /** called when the mouse is moved over the layer */\n onMouseEnter?: (event: MapMouseEvent) => void\n /** called when the mouse enters the layer */\n onMouseLeave?: (event: MapMouseEvent) => void\n /** called when the mouse leaves the layer */\n onClick?: (event: MapMouseEvent) => void\n /** called when the layer is clicked */\n onDblClick?: (event: MapMouseEvent) => void\n /** called when the layer is double-clicked */\n onContextMenu?: (event: MapMouseEvent) => void\n /** called when the context menu is triggered on the layer */\n onTouchStart?: (event: MapTouchEvent) => void\n /** called when a touch event is started on the layer */\n onTouchEnd?: (event: MapTouchEvent) => void\n /** called when a touch event is ended on the layer */\n onTouchCancel?: (event: MapTouchEvent) => void\n /** called when a touch event is cancelled on the layer */\n}\n\nconst layerEvents: any[] = [\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseOver',\n 'onMouseOut',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onClick',\n 'onDblClick',\n 'onContextMenu',\n 'onTouchStart',\n 'onTouchEnd',\n 'onTouchCancel',\n]\n\nconst drawEvents: any[] = [\n 'onCreate',\n 'onDelete',\n 'onCombine',\n 'onUncombine',\n 'onUpdate',\n 'onSelectionchange',\n 'onModechange',\n 'onRender',\n 'onActionable',\n]\n\ntype drawEventTypes = {\n onCreate?: (event: Object) => void\n /** called when a feature is created */\n onDelete?: (event: Object) => void\n /** called when a feature is deleted */\n onCombine?: (event: Object) => void\n /** called when features are combined */\n onUncombine?: (event: Object) => void\n /** called when features are uncombined */\n onUpdate?: (event: Object) => void\n /** called when a feature is updated */\n onSelectionchange?: (event: Object) => void\n /** called when the selected features change */\n onModechange?: (event: Object) => void\n /** called when the draw mode changes */\n onRender?: (event: Object) => void\n /** called when the draw canvas is re-rendered */\n onActionable?: (event: Object) => void\n /** called when the state of the draw controls changes */\n}\n\nexport { mapEvents, layerEvents, drawEvents }\nexport type { mapEventTypes, layerEventTypes, drawEventTypes }\n","const mapBase = 'mapbox://styles/mapbox'\nconst gitBase = 'https://raw.githubusercontent.com/'\nconst gishub = 'https://raw.githubusercontent.com/GIShub4/map-styles/main/'\nconst hereBase = 'https://assets.vector.hereapi.com/styles/'\n\nexport const vectorStyleList: object = {\n mb: {\n light: `${mapBase}/light-v11`,\n dark: `${mapBase}/dark-v11`,\n street: `${mapBase}/streets-v12`,\n outdoor: `${mapBase}/outdoors-v12`,\n sat: `${mapBase}/satellite-v9`,\n sat_street: `${mapBase}/satellite-streets-v12`,\n nav: `${mapBase}/navigation-guidance-day-v4`,\n nav_night: `${mapBase}/navigation-guidance-night-v4`,\n basic: `${mapBase}/cjf4m44iw0uza2spb3q0a7s41`,\n monochrome: `${mapBase}/cjv6rzz4j3m4b1fqcchuxclhb`,\n leshine: `${mapBase}/cjcunv5ae262f2sm9tfwg8i0w`,\n icecream: `${mapBase}/cj7t3i5yj0unt2rmt3y4b5e32`,\n cali: `${mapBase}/cjerxnqt3cgvp2rmyuxbeqme7`,\n northstar: `${mapBase}/cj44mfrt20f082snokim4ungi`,\n mineral: `${mapBase}/cjtep62gq54l21frr1whf27ak`,\n moonlight: `${mapBase}/cj3kbeqzo00022smj7akz3o1e`,\n frank: `${mapBase}-map-design/ckshxkppe0gge18nz20i0nrwq`,\n minimo: `${mapBase}-map-design/cksjc2nsq1bg117pnekb655h1`,\n decimal: `${mapBase}-map-design/ck4014y110wt61ctt07egsel6`,\n standard: `${mapBase}-map-design/ckr0svm3922ki18qntevm857n`,\n blueprint: `${mapBase}-map-design/cks97e1e37nsd17nzg7p0308g`,\n bubble: `${mapBase}-map-design/cksysy2nl62zp17quosctdtcc`,\n pencil: `${mapBase}-map-design/cks9iema71es417mlrft4go2k`,\n swiss_ski: `${gitBase}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,\n vintage: `${gitBase}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,\n whaam: `${gitBase}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,\n neon: `${gitBase}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,\n camoflauge: `${gitBase}jingsam/mapbox-gl-styles/master/Camouflage.json`,\n emerald: `${gitBase}jingsam/mapbox-gl-styles/master/Emerald.json`,\n runner: `${gitBase}jingsam/mapbox-gl-styles/master/Runner.json`,\n x_ray: `${gitBase}jingsam/mapbox-gl-styles/master/X-ray.json`,\n },\n here: {\n base: `${hereBase}berlin/base/mapbox/tilezen?apikey={apikey}`,\n day: `${hereBase}berlin/day/mapbox/tilezen?apikey={apikey}`,\n night: `${hereBase}berlin/night/mapbox/tilezen?apikey={apikey}`,\n },\n esri: {\n blueprint: `${gishub}esri:blueprint.json`,\n charted_territory: `${gishub}esri:charted-territory.json`,\n colored_pencil: `${gishub}esri:colored-pencil.json`,\n community: `${gishub}esri:community.json`,\n mid_century: `${gishub}esri:mid-century.json`,\n modern_antique: `${gishub}esri:modern-antique.json`,\n nat_geo: `${gishub}esri:national-geographic.json`,\n newspaper: `${gishub}esri:newspaper.json`,\n open_street_map: `${gishub}esri:open-street-map.json`,\n light_gray_canvas: `${gishub}esri:light-gray-canvas.json`,\n dark_gray_canvas: `${gishub}esri:dark-gray-canvas.json`,\n human_geo_light: `${gishub}esri:human-geography-light.json`,\n human_geo_dark: `${gishub}esri:human-geography-dark.json`,\n world_navigation: `${gishub}esri:world-navigation.json`,\n world_street: `${gishub}esri:world-street.json`,\n world_street_night: `${gishub}esri:world-street-night.json`,\n world_terrain: `${gishub}esri:world-terrain.json`,\n world_terrain_hybrid: `${gishub}esri:world-terrain-hybrid.json`,\n world_topographic: `${gishub}esri:world-topographic.json`,\n chromium: `${gishub}esri:chromium.json`,\n dreamcatcher: `${gishub}esri:dreamcatcher.json`,\n seahaven: `${gishub}esri:seahaven.json`,\n sangria: `${gishub}esri:sangria.json`,\n mercurial: `${gishub}esri:mercurial.json`,\n imagery: `${gishub}esri:imagery.json`,\n imagery_hybrid: `${gishub}esri:imagery-hybrid.json`,\n firefly: `${gishub}esri:firefly.json`,\n firefly_hybrid: `${gishub}esri:firefly-hybrid.json`,\n oceans: `${gishub}esri:oceans.json`,\n },\n}\nconst carto = 'https://{s}.basemaps.cartocdn.com/rastertiles/'\nconst stamen = 'https://stamen-tiles-{s}.a.ssl.fastly.net/'\nconst tf = 'https://{s}.tile.thunderforest.com/'\n\nexport const rasterStyleList: object = {\n osm: {\n org: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n human: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',\n cycle: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',\n topo: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',\n _copy:\n '<a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap</a>',\n },\n carto: {\n voyager: `${carto}voyager_labels_under/{z}/{x}/{y}{r}.png`,\n positron: `${carto}light_all/{z}/{x}/{y}{r}.png`,\n dark: `${carto}dark_all/{z}/{x}/{y}{r}.png`,\n _copy:\n '<a href=\"https://carto.com/attribution\" target=\"_blank\">&copy; Carto</a>',\n },\n stamen: {\n toner: `${stamen}toner/{z}/{x}/{y}{r}.png`,\n toner_lite: `${stamen}toner-lite/{z}/{x}/{y}{r}.png`,\n watercolor: `${stamen}watercolor/{z}/{x}/{y}.png`,\n terrain: `${stamen}terrain/{z}/{x}/{y}{r}.png`,\n _copy:\n '<a href=\"https://stamen.com/privacy-policy\" target=\"_blank\">&copy; Stamen Design</a>',\n },\n tf: {\n cycle: `${tf}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n trans: `${tf}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n trans_dark: `${tf}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n landscape: `${tf}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n outdoors: `${tf}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n neighbourhood: `${tf}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n spinal: `${tf}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n pioneer: `${tf}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n atlas: `${tf}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n mobile: `${tf}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n _copy:\n '<a href=\"https://thunderforest.com/privacy\" target=\"_blank\">&copy; Thunderforest</a>',\n },\n}\n","import {\n createSignal,\n createEffect,\n onMount,\n onCleanup,\n Component,\n createUniqueId,\n on,\n} from 'solid-js'\nimport { MapProvider } from '../MapProvider'\nimport { mapEvents } from '../../events'\nimport { vectorStyleList } from '../../mapStyles'\nimport type { mapEventTypes } from '../../events'\nimport type mapboxgl from 'mapbox-gl'\nimport type { MapboxOptions } from 'mapbox-gl/src/ui/map'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\nimport type { LngLatBounds } from 'mapbox-gl/src/geo/lng_lat_bounds.js'\nimport type { PaddingOptions } from 'mapbox-gl/src/geo/edge_insets.js'\nimport type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { JSX } from 'solid-js'\n\nexport type Map = mapboxgl.Map & {\n mapLib: any,\n debug: boolean,\n sourceIdList: string[]\n layerIdList: string[]\n}\n\nexport type Viewport = {\n id?: string\n point?: { x: number; y: number }\n center?: LngLatLike\n bounds?: LngLatBounds\n zoom?: number\n pitch?: number\n bearing?: number\n padding?: PaddingOptions\n inTransit?: boolean\n}\n\ntype Props = {\n /** ID for the map container element */\n id?: string\n /** Map Container CSS Style */\n style?: JSX.CSSProperties\n /** Map Container CSS Class */\n class?: string\n /** SolidJS Class List for Map Container */\n classList?: {\n [k: string]: boolean | undefined\n }\n /** Current Map View */\n viewport?: Viewport\n /** Mapbox Options\n * @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map-parameters\n */\n options?: MapboxOptions\n /** Type for pan, move and zoom transitions */\n transitionType?: 'flyTo' | 'easeTo' | 'jumpTo'\n /** Event listener for Viewport updates */\n onViewportChange?: (viewport: Viewport) => void\n /** Event listener for User Interaction */\n onUserInteraction?: (user: boolean) => void\n /** Displays Map Tile Borders */\n showTileBoundaries?: boolean\n /** Displays Wireframe if Terrain is visible */\n showTerrainWireframe?: boolean\n /** Displays Borders if Padding is set */\n showPadding?: boolean\n /** Displays Label Collision Boxes */\n showCollisionBoxes?: boolean\n /** Displays all feature outlines even if normally not drawn by style rules */\n showOverdrawInspector?: boolean\n /** Mouse Cursor Style */\n cursorStyle?: string\n //** Dark Map Style */\n darkStyle?: StyleSpecification | string\n //** Disable automatic map resize */\n disableResize?: boolean\n //** MapLibre library */\n mapLib?: any\n //** APIkey for vector service */\n apikey?: string\n //** Debug Message Mode */\n debug?: boolean\n ref?: HTMLDivElement\n /** Children within the Map Container */\n children?: any\n} & mapEventTypes\n\n/** Creates a new Map Container */\nexport const MapGL: Component<Props> = props => {\n props.id ??= createUniqueId()\n\n let map: Map\n let mapRef: HTMLDivElement\n let resizeObserver: ResizeObserver\n let mutationObserver: MutationObserver\n\n const [mapLoaded, setMapLoaded] = createSignal(null)\n const [darkMode, setDarkMode] = createSignal(\n (typeof window !== 'undefined' &&\n window.matchMedia('(prefers-color-scheme: dark)').matches) ||\n (typeof document !== 'undefined' &&\n document.body.classList.contains('dark'))\n )\n const [userInteraction, setUserInteraction] = createSignal(false)\n const [internal, setInternal] = createSignal(false)\n // debounce user interactions\n createEffect(() => props.onUserInteraction?.(userInteraction()))\n\n const debug = (text, value?) => {\n props.debug &&\n console.debug('%c[MapGL]', 'color: #0ea5e9', text, value || '')\n }\n\n const getStyle = (light, dark) => {\n const style = darkMode() && dark ? dark : light\n return typeof style === 'string' || style instanceof String\n ? style\n ?.split(':')\n .reduce((p, c) => p && p[c], vectorStyleList)\n ?.replace(\n '{apikey}',\n //@ts-ignore\n props.apikey || import.meta.env.VITE_VECTOR_API_KEY\n ) || style\n : style || { version: 8, sources: {}, layers: [] }\n }\n\n onMount(async () => {\n let mapLib = props.mapLib || (await import('mapbox-gl'))\n if (!mapLib.Map) mapLib = window['maplibregl'] || window['mapboxgl']\n\n if (!mapLib.supported?.()) throw new Error('Mapbox GL not supported')\n\n debug(`Map (v${mapLib.version}) loading...`)\n map = new mapLib.Map({\n accessToken:\n //@ts-ignore\n props.options?.accessToken || import.meta.env.VITE_MAPBOX_ACCESS_TOKEN,\n interactive: props.options?.interactive || !!props.onViewportChange,\n ...props.options,\n ...props.viewport,\n projection: props.options?.projection,\n container: mapRef,\n style: getStyle(props.options?.style, props.darkStyle),\n fitBoundsOptions: { padding: props.viewport?.padding },\n } as MapboxOptions)\n\n map.mapLib = mapLib\n map.debug = props.debug\n map.sourceIdList = []\n map.layerIdList = []\n\n map.once('load', () => {\n setMapLoaded(map)\n debug('Map loaded')\n\n // Handle User Interaction\n ;['mousedown', 'touchstart', 'wheel'].forEach(event =>\n map.on(event, evt => !evt.rotate && setUserInteraction(true))\n )\n ;['moveend', 'mouseup', 'touchend'].forEach(event =>\n map.on(event, evt => !evt.rotate && setUserInteraction(false))\n )\n\n // Listen to dark theme changes\n const darkTheme =\n typeof window !== 'undefined' &&\n window?.matchMedia('(prefers-color-scheme: dark)')\n darkTheme?.addEventListener('change', () => {\n setDarkMode(darkTheme.matches)\n debug('Set dark theme to:', darkTheme.matches?.toString())\n })\n mutationObserver = new MutationObserver(() => {\n const darkTheme = document.body.classList.contains('dark')\n setDarkMode(darkTheme)\n debug('Set theme to:', darkTheme)\n })\n mutationObserver.observe(document.body, { attributes: true })\n\n // Listen to map container size changes\n // if (!props.disableResize) {\n // resizeObserver = new ResizeObserver(() => {\n // map?.resize()\n // debug('Map resized')\n // })\n // resizeObserver.observe(mapRef as Element)\n // }\n\n // Hook up events\n mapEvents.forEach(item => {\n const prop = props[item]\n let isFirstMessage = true\n if (prop) {\n const event = item.slice(2).toLowerCase()\n if (typeof prop === 'function') {\n map.on(event, e => {\n prop(e)\n isFirstMessage && debug(`Map '${event}' event:`, e)\n isFirstMessage = false\n })\n } else {\n Object.keys(prop).forEach(layerId => {\n map.on(event as any, layerId, e => {\n prop[layerId](e)\n isFirstMessage &&\n debug(`Map '${event}' event on '${layerId}':`, e)\n isFirstMessage = false\n })\n })\n }\n }\n })\n\n // Update Viewport\n map.on('move', event => {\n const viewport: Viewport = {\n ...props.viewport,\n id: props.id,\n // point: { x: event.originalEvent?.x, y: event.originalEvent?.y },\n center: props.viewport?.center?.lat\n ? map.getCenter()\n : [map.getCenter().lng, map.getCenter().lat],\n zoom: map.getZoom(),\n pitch: map.getPitch(),\n bearing: map.getBearing(),\n inTransit: true,\n }\n setInternal(true)\n !event.viewport && props.onViewportChange?.(viewport)\n })\n\n map.on('moveend', event => {\n !event.rotate &&\n props.onViewportChange?.({ ...props.viewport, inTransit: false })\n setInternal(false)\n })\n })\n })\n\n // Hook up viewport event\n createEffect(\n on(\n () => props.viewport,\n vp => {\n if (props.id !== vp?.id || internal()) return\n const viewport = {\n ...vp,\n ...(vp.bounds\n ? map.cameraForBounds(vp.bounds, {\n padding: vp?.padding,\n })\n : null),\n }\n map.stop()[props.transitionType || 'flyTo'](viewport)\n debug(`Update Viewport (${props.transitionType || 'flyTo'}):`, viewport)\n },\n { defer: true }\n )\n )\n\n // Update Projection\n createEffect(() => {\n const proj = props.options?.projection\n if (!map || !proj) return\n map.setProjection(proj)\n debug('Set Projection to:', proj)\n })\n\n // Update Cursor\n createEffect(() => {\n const cur = props.cursorStyle\n if (!map || !cur) return\n map.getCanvas().style.cursor = cur\n debug('Set Cursor to:', cur)\n })\n\n const insertLayers = (list, layers) => {\n layers.forEach(layer => {\n const index = list.findIndex(i =>\n layer.metadata.smg.beforeType\n ? i.type === layer.metadata.smg.beforeType\n : i.id === layer.metadata.smg.beforeId\n )\n list =\n index === -1\n ? [...list, layer]\n : [...list.slice(0, index), layer, ...list.slice(index + 1)]\n })\n return list\n }\n\n // Update map style\n createEffect(prev => {\n const style = getStyle(props.options?.style, props.darkStyle)\n if (map?.isStyleLoaded() && prev !== style) {\n const oldStyle = map.getStyle()\n const oldLayers = oldStyle.layers.filter(l =>\n map.layerIdList.includes(l.id)\n )\n const oldSources = Object.keys(oldStyle.sources)\n .filter(s => map.sourceIdList.includes(s))\n .reduce((obj, key) => ({ ...obj, [key]: oldStyle.sources[key] }), {})\n\n map.setStyle(style)\n map.once('styledata', () => {\n if (!oldLayers) return\n const newStyle = map.getStyle()\n map.setStyle({\n ...newStyle,\n sources: { ...newStyle.sources, ...oldSources },\n layers: insertLayers(newStyle.layers, oldLayers),\n fog: oldStyle.fog,\n terrain: oldStyle.terrain,\n })\n debug('Set Mapstyle to:', style)\n })\n }\n return style\n }, props.options?.style)\n\n // Update debug features\n ;[\n 'showTileBoundaries',\n 'showTerrainWireframe',\n 'showCollisionBoxes',\n 'showPadding',\n 'showOverdrawInspector',\n ].forEach(item => {\n createEffect(() => {\n const prop = props[item]\n if (!map || !prop) return\n map[item] = prop\n debug(`Set ${item} to:`, prop)\n })\n })\n\n onCleanup(() => {\n resizeObserver?.disconnect()\n mutationObserver?.disconnect()\n map?.remove()\n debug('Map removed')\n })\n\n return (\n <>\n <div\n ref={mapRef}\n id={props.id}\n class={props?.class}\n classList={props?.classList}\n style={\n props?.class || props?.classList\n ? null\n : props.style || {\n position: 'absolute',\n inset: 0,\n 'z-index': -1,\n }\n }\n />\n {mapLoaded() &&\n <MapProvider map={mapLoaded()}>\n {props.children}\n </MapProvider>\n }\n </>\n )\n}\n","import {\n onCleanup,\n createEffect,\n Component,\n createContext,\n useContext,\n createUniqueId,\n} from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { SourceSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport { rasterStyleList } from '../../mapStyles'\n\nconst SourceContext = createContext<string>()\nexport const useSourceId = (): string => useContext(SourceContext)\n\ntype Props = {\n /** @optional Source ID for referencing non nexted Layers */\n id?: string\n /** @see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/ */\n source: SourceSpecification\n /** The map layers associated with this source */\n children?: any\n}\n\nexport const Source: Component<Props> = props => {\n const [ctx] = useMapContext()\n props.id ??= createUniqueId()\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #ec4899', text, value || '')\n }\n\n const lookup = url => {\n const s = url?.split(':').reduce((p, c) => p && p[c], rasterStyleList)\n const source = s\n ? {\n ...props.source,\n url: '',\n tiles: [\n s\n .replace(\n '{apikey}', //@ts-ignore\n props.source.apikey || import.meta.env.VITE_RASTER_API_KEY\n )\n .replace('{r}', window.devicePixelRatio > 1 ? '@2x' : ''),\n ],\n attribution: rasterStyleList[url.split(':')[0]]._copy,\n }\n : props.source\n\n source.tiles &&\n (source.tiles = ['a', 'b', 'c'].map(i =>\n source.tiles[0].replace('{s}', i)\n ))\n\n return source\n }\n\n // Add Source\n ctx.map.addSource(props.id, lookup(props.source.url))\n ctx.map.sourceIdList.push(props.id)\n debug('Add Source:', props.id)\n\n // Update Data\n const source = ctx.map.getSource(props.id)\n switch (props.source.type) {\n case 'geojson':\n createEffect(() => {\n const data = props.source.data\n if (!ctx.map.isSourceLoaded(props.id)) return\n source.setData(data || {})\n debug('Update GeoJSON Data:', props.id)\n })\n break\n case 'image':\n createEffect(() => {\n const url = props.source.url\n const coords = props.source.coordinates\n if (!ctx.map.isSourceLoaded(props.id)) return\n source.updateImage(url, coords)\n debug('Update Image Data:', props.id)\n })\n break\n case 'vector':\n createEffect(() => {\n const url = props.source.url\n const tiles = props.source.tiles\n if (!ctx.map.isSourceLoaded(props.id)) return\n url ? source.setUrl(url) : source.setTiles(tiles)\n debug('Update Vector Data:', props.id)\n })\n break\n case 'raster':\n createEffect(() => {\n const src = lookup(props.source.url)\n if (!ctx.map.isSourceLoaded(props.id)) return\n src.url ? source.setUrl(src.url) : source.setTiles(src.tiles)\n debug('Update Raster Data:', props.id)\n })\n break\n }\n\n // Remove Source\n onCleanup(() => {\n ctx.map\n ?.getStyle()\n .layers.forEach(\n layer => layer.source === props.id && ctx.map.removeLayer(layer.id)\n )\n ctx.map?.getSource(props.id) && ctx.map?.removeSource(props.id)\n debug('Remove Source:', props.id)\n })\n\n return (\n <SourceContext.Provider value={props.id}>\n {props.children}\n </SourceContext.Provider>\n )\n}\n","import { onCleanup, createEffect, Component, createUniqueId } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { useSourceId } from '../Source'\nimport { layerEvents } from '../../events'\nimport type { layerEventTypes } from '../../events'\nimport type {\n FilterSpecification,\n StyleSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\nimport type { CustomLayerInterface } from 'mapbox-gl/src/style/style_layer/custom_style_layer'\n\nconst diff = (\n newProps: StyleSpecification = {},\n prevProps: StyleSpecification = {}\n): [string, any][] => {\n const keys = new Set([...Object.keys(newProps), ...Object.keys(prevProps)])\n return [...keys].reduce((acc, key: string) => {\n const value = newProps[key]\n if (value !== prevProps[key]) {\n acc.push([key, value])\n }\n return acc\n }, [])\n}\n\ntype Props = {\n id?: string\n /** A string that uniquely identifies the layer. If not provided, a unique ID will be generated. */\n style?: StyleSpecification\n /** A Mapbox Style Specification object that defines the visual appearance of the layer. */\n customLayer?: CustomLayerInterface\n /** An object that implements the `CustomLayerInterface` interface, which allows you to create custom layers using WebGL. */\n filter?: FilterSpecification\n /** A Mapbox filter specification that defines which features of the layer to include or exclude from the layer. */\n visible?: boolean\n /** A boolean that determines whether the layer is visible or not. */\n sourceId?: string\n /** A string that specifies the ID of the source that the layer uses for its data. */\n beforeType?:\n | 'background'\n | 'fill'\n | 'line'\n | 'symbol'\n | 'raster'\n | 'circle'\n | 'fill-extrusion'\n | 'heatmap'\n | 'hillshade'\n | 'sky'\n /** A string that specifies the type of layer before which the current layer should be inserted. */\n beforeId?: string\n /** A string that specifies the ID of the layer before which the current layer should be inserted. */\n featureState?: { id: number | string; state: object }\n /** An object that specifies the state of a feature in the layer. The object consists of an ID (either a number or a string) and an object containing the state. */\n children?: any\n /** Any content that should be rendered within the layer. */\n} & layerEventTypes\n\nexport const Layer: Component<Props> = props => {\n const [ctx] = useMapContext()\n const sourceId: string = props.style?.source || useSourceId()\n props.id ??= createUniqueId()\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #10b981', text, value || '')\n }\n\n // Add Layer\n ctx.map.addLayer(\n props.customLayer || {\n ...props.style,\n id: props.id,\n source: sourceId,\n metadata: {\n smg: { beforeType: props.beforeType, beforeId: props.beforeId },\n },\n },\n props.beforeType\n ? ctx.map\n .getStyle()\n .layers.find(l => l.type === props.beforeType)?.id\n : props.beforeId\n )\n ctx.map.layerIdList.push(props.id)\n debug('Add Layer:', props.id)\n\n // Hook up events\n layerEvents.forEach(item => {\n if (props[item]) {\n const event = item.slice(2).toLowerCase()\n ctx.map.on(event, props.id, evt => {\n props[item](evt)\n debug(`Layer '${event}' event on '${props.id}':`, evt)\n })\n }\n })\n\n // Update Style\n createEffect((prev: StyleSpecification) => {\n const style = props.style\n if (style === prev) return\n\n if (style.layout !== prev?.layout)\n diff(style.layout, prev?.layout).forEach(([key, value]) =>\n ctx.map.setLayoutProperty(props.id, key, value, { validate: false })\n )\n\n if (style.paint !== prev?.paint)\n diff(style.paint, prev?.paint).forEach(([key, value]) =>\n ctx.map.setPaintProperty(props.id, key, value, { validate: false })\n )\n\n if (style.minzoom !== prev?.minzoom || style.maxzoom !== prev?.maxzoom)\n ctx.map.setLayerZoomRange(props.id, style.minzoom, style.maxzoom)\n\n if (style.filter !== prev?.filter)\n ctx.map.setFilter(props.id, style.filter, { validate: false })\n\n debug('Update Layer Style:', props.id)\n return style\n }, props.style)\n\n // Update Visibility\n createEffect((prev: boolean) => {\n if (props.visible === prev) return\n\n ctx.map.setLayoutProperty(\n props.id,\n 'visibility',\n props.visible ? 'visible' : 'none',\n { validate: false }\n )\n debug(`Update Visibility (${props.id}):`, props.visible)\n return props.visible\n }, props.visible)\n\n // Update Filter\n createEffect(async () => {\n if (!props.filter) return\n\n !ctx.map.isStyleLoaded() && (await ctx.map.once('styledata'))\n ctx.map.setFilter(props.id, props.filter)\n debug(`Update Filter (${props.id}):`, props.filter)\n })\n\n // Update Feature State\n createEffect(async () => {\n if (!props.featureState || props.featureState.id === null) return\n\n !ctx.map.isStyleLoaded() && (await ctx.map.once('styledata'))\n\n ctx.map.removeFeatureState({\n source: sourceId,\n sourceLayer: props.style['source-layer'],\n })\n ctx.map.setFeatureState(\n {\n source: sourceId,\n sourceLayer: props.style['source-layer'],\n id: props.featureState.id,\n },\n props.featureState.state\n )\n })\n\n //Remove Layer\n onCleanup(() => ctx.map?.getLayer(props.id) && ctx.map?.removeLayer(props.id))\n\n return props.children\n}\n","import { onCleanup, createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Fog } from 'mapbox-gl'\n\ntype Props = {\n /** Fog/Atmosphere Specifications */\n style?: Fog\n}\n\nexport const Atmosphere: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add or Update Atmosphere Layer\n createEffect(() => ctx.map.setFog(props.style || {}))\n\n // Remove Atmosphere Layer\n onCleanup(() => ctx.map.setFog(null))\n\n return null\n}\n","import { createEffect, VoidComponent, createUniqueId } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { useSourceId } from '../Source'\nimport type { TerrainSpecification } from 'mapbox-gl'\n\nexport const Terrain: VoidComponent<TerrainSpecification> = (props: TerrainSpecification) => {\n const [ctx] = useMapContext()\n let sourceId: string = useSourceId()\n\n // Add Terrain Source if not already defined\n if (!sourceId && !props.source) {\n sourceId = createUniqueId()\n ctx.map.addSource(sourceId,\n {\n type: 'raster-dem',\n url: ctx.map.isMapLibre\n ? 'https://demotiles.maplibre.org/terrain-tiles/tiles.json'\n : 'mapbox://mapbox.terrain-rgb',\n tileSize: ctx.map.isMapLibre ? 256 : 512,\n maxzoom: ctx.map.isMapLibre ? undefined : 14\n }\n )\n ctx.map.sourceIdList.push(sourceId)\n }\n\n // Add or Update Terrain Layer\n createEffect(() => {\n ctx.map.setTerrain({\n exaggeration: props.exaggeration || 1,\n source: props.source || sourceId,\n })\n })\n\n return null\n}\n","import { createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Options as AttributionOptions } from 'mapbox-gl/src/ui/control/attribution_control'\nimport type { Options as FullscreenOptions } from 'mapbox-gl/src/ui/control/fullscreen_control'\nimport type { Options as GeolocateOptions } from 'mapbox-gl/src/ui/control/geolocate_control'\nimport type { Options as NavigationOptions } from 'mapbox-gl/src/ui/control/navigation_control'\nimport type { Options as ScaleOptions } from 'mapbox-gl/src/ui/control/scale_control'\n\ntype ControlType = 'navigation' | 'scale' | 'attribution' | 'fullscreen' | 'geolocate'\n\ntype Props = {\n type?: ControlType\n /** a string that specifies the type of control to be displayed. It can be one of 'navigation', 'scale', 'attribution', 'fullscreen', or 'geolocate' */\n options?:\n | NavigationOptions\n | ScaleOptions\n | AttributionOptions\n | FullscreenOptions\n | GeolocateOptions\n | object\n /** an optional object that contains options specific to the control type */\n custom?: any\n /** an optional field that allows passing a custom control element. */\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n /** a string that specifies the position of the control on the map. It can be one of 'top-left', 'top-right', 'bottom-left', or 'bottom-right' */\n}\n\nexport const Control: VoidComponent<Props> = props => {\n const [ctx] = useMapContext()\n const controlClasses = new Map<ControlType, any>([\n ['navigation', ctx.map.mapLib.NavigationControl],\n ['scale', ctx.map.mapLib.ScaleControl],\n ['attribution', ctx.map.mapLib.AttributionControl],\n ['geolocate', ctx.map.mapLib.GeolocateControl],\n ['fullscreen', ctx.map.mapLib.FullscreenControl],\n ])\n const ControlClass = props.custom || controlClasses.get(props.type || 'navigation')\n if (!ControlClass) throw new Error(`Unknown control type: ${props.type}`)\n\n // Add or Update Control\n createEffect(() => {\n const control = new ControlClass(props.options)\n control && ctx.map.hasControl(control) && ctx.map.removeControl(control)\n ctx.map.addControl(control, props.position)\n })\n\n return null\n}\n","import { onCleanup, createEffect, Component, untrack } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type {\n Popup as PopupType,\n PopupOptions,\n Marker as MarkerType,\n MarkerOptions,\n LngLatLike\n} from 'mapbox-gl'\n\ntype Props = {\n /** Options for the Mapbox GL JS marker */\n options?: MarkerOptions & {\n /** Options for the Mapbox GL JS popup that is associated with the marker */\n popup: PopupOptions\n }\n /** The geographical location to place the marker */\n lngLat: LngLatLike\n /** Whether the marker's associated popup should be open */\n openPopup?: boolean\n /** Whether the marker is draggable */\n draggable?: boolean\n /** A function that is called when the marker is dragged to a new location */\n onLngLatChange?: (lngLat: number[]) => void\n /** A function that is called when the marker's associated popup is closed */\n onClose?: () => void\n /** A function that is called when the marker starts being dragged */\n onDragStart?: () => void\n /** A function that is called when the marker stops being dragged */\n onDragEnd?: () => void\n /** The content to be displayed in the marker's associated popup */\n children?: any\n}\n\nexport const Marker: Component<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n let marker: MarkerType = null\n let popup: PopupType = null\n\n if (!props.lngLat) throw new Error('Marker - lngLat is required')\n\n // Add or Update Marker\n createEffect(() => {\n const ops = { ...props.options }\n const pops = { ...props.options?.popup }\n if (!ctx.map) return\n const mapboxgl = ctx.map.mapLib\n untrack(() => {\n popup?.remove()\n popup = props.children\n ? new mapboxgl.Popup(pops)\n .setHTML(props.children)\n .on('close', () => props.onClose?.())\n : null\n\n marker?.remove()\n marker = new mapboxgl.Marker(ops)\n .setPopup(popup)\n .on('dragstart', () => props.onDragStart?.())\n .on('dragend', () => props.onDragEnd?.())\n .on('drag', () => props.onLngLatChange?.(marker.getLngLat().toArray()))\n .setDraggable(props.draggable || props.options?.draggable)\n .setLngLat(props.lngLat)\n .addTo(ctx.map)\n props.openPopup !== popup?.isOpen() && marker.togglePopup()\n })\n })\n\n // Toggle Popup\n createEffect(\n () => props.openPopup !== popup?.isOpen() && marker.togglePopup()\n )\n\n // Update Position\n createEffect(() => marker.setLngLat(props.lngLat))\n\n // Update Popup Content\n createEffect(() => popup?.setHTML(props.children))\n\n // Update Draggable\n createEffect(() => marker.setDraggable(props.draggable))\n\n // Remove Marker\n onCleanup(() => marker?.remove())\n\n return null\n}\n","import { onCleanup, createEffect, Component, untrack } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Popup as PopupType, PopupOptions, LngLatLike } from 'mapbox-gl'\n\ntype Props = {\n /** Options for configuring the popup */\n options?: PopupOptions\n /** Flag for tracking the mouse pointer */\n trackPointer?: boolean\n /** Longitude and latitude for the popup */\n lngLat?: LngLatLike\n /** Callback for when the popup is closed */\n onClose?: () => void\n /** Children to display within the popup */\n children?: any\n}\n\nexport const Popup: Component<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n let popup: PopupType = null\n\n if (!props.trackPointer && !props.lngLat)\n throw new Error('Popup - lngLat or trackPointer is required')\n\n // Add or Update Popup\n createEffect(() => {\n const ops = { ...props.options }\n if (!ctx.map) return\n const mapboxgl = ctx.map.mapLib\n untrack(() => {\n popup?.remove()\n popup = new mapboxgl.Popup(\n props.trackPointer\n ? { ...ops, closeOnClick: false, closeButton: false }\n : { focusAfterOpen: false, ...ops }\n )\n .setHTML(props.children || '')\n .setLngLat(props.lngLat)\n .on('close', () => props.onClose?.())\n .addTo(ctx.map)\n })\n })\n\n // Update Position\n createEffect(() =>\n props.trackPointer ? popup.trackPointer() : popup.setLngLat(props.lngLat)\n )\n\n // Update Content\n createEffect(() => popup.setHTML(props.children || ''))\n\n // Remove Popup\n onCleanup(() => popup?.remove())\n\n return null\n}\n","import {\n onCleanup,\n createSignal,\n createEffect,\n VoidComponent,\n untrack,\n} from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type {\n StyleImageInterface,\n StyleImageMetadata,\n} from 'mapbox-gl/src/style/style_image'\n\nconst PATTERN = {\n diagonal_l: { size: 20, path: 'M20 0 0 20M-10 10 10-10M10 30 30 10' },\n diagonal_r: { size: 20, path: 'M0 0 20 20M30 10 10-10M10 30-10 10' },\n horizontal: { size: 14, path: 'M7 0V20' },\n vertical: { size: 14, path: 'M0 7H20' },\n cross: { size: 18, path: 'M9 0V18M0 9H18' },\n hash: { size: 30, path: 'M15 0 30 15 15 30 0 15Z' },\n chevron_h: { size: 20, path: 'M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30' },\n chevron_v: { size: 20, path: 'M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5' },\n square: { size: 20, path: 'M8 8H12V12H8Z', fill: true },\n hex: { size: 50, path: 'M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50' },\n circle: {\n size: 25,\n path: 'M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15',\n fill: true,\n },\n}\n\nexport const patternList = Object.keys(PATTERN)\n\nexport type Color =\n | `#${string}`\n | `rgb(${number}, ${number}, ${number})`\n | `rgba(${number}, ${number}, ${number}, ${number})`\n | `hsl(${number}, ${number}%, ${number}%)`\n | `hsla(${number}, ${number}%, ${number}%, ${number})`\n\ntype Props = {\n id: string\n /** The unique identifier for the image. */\n source?:\n | HTMLImageElement\n | ImageBitmap\n | ImageData\n | SVGElement\n | { width: number; height: number; data: Uint8Array | Uint8ClampedArray }\n | StyleImageInterface\n | string\n /** The image to be used for the image component. */\n options?: StyleImageMetadata & {\n fill?: Color\n stroke?: Color\n transform?: string\n }\n /** The options for the image */\n pattern?: {\n type: string\n color: Color\n background: Color\n lineWith: number\n }\n /** The pattern to be used for the image component. */\n}\n\nexport const MGL_Image: VoidComponent<Props> = props => {\n const [ctx] = useMapContext()\n const [size, setSize] = createSignal({ width: 0, height: 0 })\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #10b981', text, value || '')\n }\n\n // Remove Image\n onCleanup(() => {\n ctx.map?.hasImage(props.id) && ctx.map?.removeImage(props.id)\n debug('Remove Image:', props.id)\n })\n\n // Add or Update Image\n createEffect(() => {\n if (!props.id) throw new Error('Image - ID is required')\n if (!props.source && !props.pattern)\n throw new Error('Image - Image or Pattern is required')\n\n const ops = props.pattern\n ? { pixelRatio: 2, ...props.options }\n : props.options\n\n _loadImage(props.source || _createPattern(props.pattern), data => {\n const { width, height } = data\n if (ctx.map && !ctx.map.hasImage(props.id))\n ctx.map.addImage(props.id, data, ops)\n if (\n !props.pattern &&\n untrack(() => width === size().width && height === size().height)\n ) {\n ctx.map.updateImage(props.id, data)\n ctx.map.triggerRepaint()\n } else {\n ctx.map.removeImage(props.id)\n ctx.map.addImage(props.id, data, ops)\n }\n setSize({ width, height })\n debug('Add Image:', props.id)\n ctx.map.on('style.load', () => {\n if (ctx.map.hasImage(props.id)) return\n ctx.map.addImage(props.id, data, ops)\n debug('Re-Add Image:', props.id)\n })\n })\n })\n\n // Load Image / SVG\n const _loadImage = (image, callback) => {\n if (typeof image == 'string' && image?.trimStart().startsWith('<svg')) {\n image = new DOMParser().parseFromString(image, 'image/svg+xml')\n .childNodes[0]\n }\n if (image instanceof SVGElement) {\n props.options?.fill && image.setAttribute('fill', props.options.fill)\n props.options?.stroke &&\n image.setAttribute('stroke', props.options.stroke)\n image = new XMLSerializer().serializeToString(image)\n }\n if (typeof image !== 'string') return callback(image)\n ctx.map.loadImage(image, async (error, imageData) => {\n if (error) {\n if (typeof image == 'string' && image?.trimEnd().endsWith('.svg')) {\n image = await (await fetch(image)).text()\n image = new DOMParser().parseFromString(image, 'image/svg+xml')\n .childNodes[0]\n image.setAttribute('fill', props.options.fill)\n image.setAttribute('stroke', props.options.stroke)\n image.setAttribute('transform', props.options.transform)\n image = new XMLSerializer().serializeToString(image)\n }\n const img = new Image()\n img.crossOrigin = 'Anonymous'\n img.onload = () => {\n const canvas = document.createElement('canvas')\n canvas.width = Math.max(img.width, 50)\n canvas.height = Math.max(img.height, 50)\n const ctx = canvas.getContext('2d')\n ctx.imageSmoothingEnabled = true\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height)\n return callback(ctx.getImageData(0, 0, canvas.width, canvas.height))\n }\n img.src = image.trimStart().startsWith('<svg')\n ? 'data:image/svg+xml;charset=utf-8,' + image\n : image\n } else {\n return callback(imageData)\n }\n })\n }\n\n const _createPattern = pattern => {\n const p = PATTERN[pattern.type]\n return {\n width: p.size,\n height: p.size,\n data: new Uint8Array(p.size * p.size * 4),\n onAdd: function () {\n let canvas = document.createElement('canvas')\n canvas.width = canvas.height = p.size\n this.ctx = canvas.getContext('2d', { willReadFrequently: true })\n },\n render: function () {\n this.ctx.fillStyle = pattern.background || 'transparent'\n this.ctx.fillRect(0, 0, this.width, this.height)\n this.ctx.strokeStyle = this.ctx.fillStyle = pattern.color || 'black'\n this.ctx.lineWidth = pattern.lineWith || 1\n this.ctx.stroke(new Path2D(p.path))\n if (p.fill) this.ctx.fill(new Path2D(p.path))\n this.data = this.ctx.getImageData(0, 0, this.width, this.height).data\n return true\n },\n }\n }\n\n return null\n}\n","import { createEffect, Component, onCleanup } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { LngLatLike } from 'mapbox-gl'\n\n// linearly interpolate between two positions [x,y,z] based on time\nconst lerp = (a: number[], b: number[], t: number): number[] => a.map((_, idx) => (1.0 - t) * a[idx] + t * b[idx])\n\n// sphericaly interpolate between two positions [x,y,z] based on time\nconst slerp = (a: number[], b: number[], t: number): number[] => {\n const dotProduct = a.map((_, idx) => a[idx] * b[idx]).reduce((m, n) => m + n)\n const theta = Math.acos(dotProduct)\n\n return a.map(\n (_, idx) =>\n (Math.sin((1 - t) * theta) / Math.sin(theta)) * a[idx] +\n (Math.sin(t * theta) / Math.sin(theta)) * b[idx]\n )\n}\n\n// calculations from: https://easings.net\nconst easeQuad = {\n in: (x: number): number => x * x,\n out: (x: number): number => 1 - (1 - x) * (1 - x),\n inOut: (x: number): number =>\n x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,\n}\n\n/** Options for rotating the globe. */\ninterface RotateGlobeOptions {\n /** The number of seconds per revolution. */\n secPerRev?: number\n /** The maximum zoom level for spinning the globe. */\n maxSpinZoom?: number\n /** The zoom level at which the spinning slows down. */\n slowSpinZoom?: number\n}\n\n/** Options for rotating the viewport. */\ninterface RotateViewportOptions {\n /** The number of seconds per revolution. */\n secPerRev?: number\n /** The pitch angle in degrees. */\n pitch?: number\n /** The center of rotation. */\n around?: LngLatLike\n}\n\n/** Props for the component. */\ntype Props = {\n /** Whether to rotate the globe. */\n rotateGlobe?: boolean | RotateGlobeOptions\n /** Whether to rotate the viewport. */\n rotateViewport?: boolean | RotateViewportOptions\n /** Whether to reverse the rotation direction. */\n reverse?: boolean\n /** Whether to reset the rotation when stopped. */\n resetWhenStopped?: boolean\n /** Translation options. */\n translate?: {\n /** The type of translation. */\n type?: 'line' | 'sphere'\n /** The starting position. */\n start: [number, number, number]\n /** The ending position. */\n end: [number, number, number]\n /** The target position. */\n target: LngLatLike\n /** The ending target position. */\n targetEnd?: LngLatLike\n /** The easing function to use. */\n easing?: 'in' | 'out' | 'inOut'\n /** Whether to loop the translation. */\n loop?: boolean\n /** The duration of the translation in milliseconds. */\n duration: number\n }\n /** The children to render. */\n children?: any\n}\n\nexport const Camera: Component<Props> = props => {\n const [ctx] = useMapContext()\n if (!ctx.map) return null\n let animationTime = 0.1\n let isReverse = false\n\n const updateCameraPosition = async ([lng, lat, alt]: number[], target: LngLatLike) => {\n const camera = ctx.map.getFreeCameraOptions()\n camera.position = ctx.map.mapLib.MercatorCoordinate.fromLngLat([lng, lat], alt)\n camera.lookAtPoint(target)\n ctx.map.setFreeCameraOptions(camera)\n }\n\n const frame = () => {\n props.translate && window.requestAnimationFrame(frame)\n const params = [\n props.translate.start,\n props.translate.end,\n props.translate.easing\n ? easeQuad[props.translate.easing](animationTime)\n : animationTime,\n ] as const\n const position =\n props.translate.type === 'line' ? lerp(...params) : slerp(...params)\n\n updateCameraPosition(position, props.translate.target)\n\n if (!props.translate.loop && (animationTime > 1.0 || animationTime < 0.0))\n isReverse = !isReverse\n animationTime = isReverse ? animationTime - 0.001 : animationTime + 0.001\n }\n\n createEffect(() => {\n props.translate && window.requestAnimationFrame(frame)\n })\n\n const options = { duration: 1000, easing: n => n }\n\n const rotateGlobe = (): void => {\n if (ctx.userInteraction) return\n const {\n secPerRev = 120,\n maxSpinZoom = 5,\n slowSpinZoom = 3,\n }: RotateGlobeOptions = props.rotateGlobe as RotateGlobeOptions\n\n const zoom: number = ctx.map.getZoom()\n if (zoom > maxSpinZoom) return\n let distancePerSecond: number = 360 / secPerRev\n if (zoom > slowSpinZoom)\n distancePerSecond *= (maxSpinZoom - zoom) / (maxSpinZoom - slowSpinZoom)\n const center: mapboxgl.LngLat = ctx.map.getCenter()\n center.lng = props.reverse\n ? center.lng + distancePerSecond\n : center.lng - distancePerSecond\n ctx.map.easeTo({ center, ...options }, { rotate: true })\n }\n\n const rotateViewport = (): void => {\n if (!props.rotateViewport || ctx.userInteraction) return\n const rotateViewport = props.rotateViewport as RotateViewportOptions\n const secPerRev = rotateViewport?.secPerRev || 60\n const bearing = props.reverse\n ? ctx.map.getBearing() + 360 / secPerRev\n : ctx.map.getBearing() - 360 / secPerRev\n const pitch = rotateViewport?.pitch || 60\n const around = rotateViewport?.around\n ctx.map.easeTo({ bearing, pitch, around, ...options }, { rotate: true })\n }\n\n const onEnd = () => (props.rotateGlobe ? rotateGlobe() : rotateViewport())\n ctx.map.on('moveend', onEnd).on('dragend', onEnd)\n\n let originalCenter: mapboxgl.LngLatLike\n createEffect(() => {\n if (props.rotateGlobe == undefined) return\n if (props.rotateGlobe) {\n originalCenter = ctx.map.getCenter()\n rotateGlobe()\n } else {\n props.resetWhenStopped\n ? ctx.map.stop().easeTo({ center: originalCenter })\n : ctx.map.stop()\n }\n })\n\n createEffect(() => {\n if (props.rotateViewport == undefined) return\n props.rotateViewport\n ? rotateViewport()\n : props.resetWhenStopped\n ? ctx.map.stop().resetNorthPitch()\n : ctx.map.stop()\n })\n\n onCleanup(() => ctx.map.off('moveend', onEnd).off('dragend', onEnd))\n\n return props.children\n}\n","import { onCleanup, createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Light as LightSpecification } from 'mapbox-gl'\n\ntype Props = {\n /** Light Specifications */\n style: LightSpecification\n}\nexport const Light: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add or Update Light Layer\n createEffect(() => ctx.map.setLight(props.style || {}))\n\n // Remove Light Layer\n onCleanup(() => ctx.map?.setLight(null))\n\n return null\n}\n","import { onCleanup, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { drawEvents } from '../../events'\nimport type { drawEventTypes } from '../../events'\n\ntype Props = {\n /** Draw Library */\n lib: any\n /** Draw Options */\n options?: object\n /** Draw Control Position */\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n /** Draw Control Instance */\n getInstance?: (object) => void\n} & drawEventTypes\n\nexport const Draw: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add Draw Control\n const draw = new props.lib(props.options)\n ctx.map.addControl(draw, props.position || 'top-right')\n props.getInstance && props.getInstance(draw)\n\n // Hook up events\n const eventList: Record<string, (evt: any) => void> = {}\n drawEvents.forEach(item => {\n if (props[item]) {\n const event = `draw.${item.slice(2).toLowerCase()}`\n const fn = evt => props[item](evt)\n eventList[event] = fn\n ctx.map.on(event, fn)\n }\n })\n\n // Remove Draw Control\n onCleanup(() => {\n // Remove Events\n Object.keys(eventList).forEach(event => ctx.map.off(event, eventList[event]))\n // Remove Control\n ctx.map?.removeControl(draw)\n })\n\n return null\n}\n"],"names":["state","setState","createStore","map","userInteraction","MapContext","createContext","useMapContext","useContext","MapProvider","props","_$createComponent","Provider","value","children","mapEvents","layerEvents","drawEvents","mapBase","gitBase","gishub","hereBase","vectorStyleList","mb","light","dark","street","outdoor","sat","sat_street","nav","nav_night","basic","monochrome","leshine","icecream","cali","northstar","mineral","moonlight","frank","minimo","decimal","standard","blueprint","bubble","pencil","swiss_ski","vintage","whaam","neon","camoflauge","emerald","runner","x_ray","here","base","day","night","esri","charted_territory","colored_pencil","community","mid_century","modern_antique","nat_geo","newspaper","open_street_map","light_gray_canvas","dark_gray_canvas","human_geo_light","human_geo_dark","world_navigation","world_street","world_street_night","world_terrain","world_terrain_hybrid","world_topographic","chromium","dreamcatcher","seahaven","sangria","mercurial","imagery","imagery_hybrid","firefly","firefly_hybrid","oceans","carto","stamen","tf","rasterStyleList","osm","org","human","cycle","topo","_copy","voyager","positron","toner","toner_lite","watercolor","terrain","trans","trans_dark","landscape","outdoors","neighbourhood","spinal","pioneer","atlas","mobile","MapGL","mapRef","mutationObserver","id","createUniqueId","mapLoaded","setMapLoaded","createSignal","darkMode","setDarkMode","window","matchMedia","matches","document","body","classList","contains","setUserInteraction","internal","setInternal","createEffect","onUserInteraction","debug","text","console","getStyle","style","String","split","reduce","p","c","replace","apikey","env","VITE_VECTOR_API_KEY","version","sources","layers","onMount","async","mapLib","import","Map","supported","Error","accessToken","options","VITE_MAPBOX_ACCESS_TOKEN","interactive","onViewportChange","viewport","projection","container","darkStyle","fitBoundsOptions","padding","sourceIdList","layerIdList","once","forEach","event","on","evt","rotate","darkTheme","addEventListener","toString","MutationObserver","observe","attributes","item","prop","isFirstMessage","slice","toLowerCase","e","Object","keys","layerId","center","lat","getCenter","lng","zoom","getZoom","pitch","getPitch","bearing","getBearing","inTransit","vp","bounds","cameraForBounds","stop","transitionType","defer","proj","setProjection","cur","cursorStyle","getCanvas","cursor","prev","isStyleLoaded","oldStyle","oldLayers","filter","l","includes","oldSources","s","obj","key","setStyle","newStyle","insertLayers","list","layer","index","findIndex","i","metadata","smg","beforeType","type","beforeId","fog","onCleanup","disconnect","remove","_el$","_tmpl$","_$use","_$effect","_p$","_v$","_v$2","class","_v$3","_v$4","position","inset","_$setAttribute","_$className","_$classList","_$style","undefined","_$memo","_c$","SourceContext","useSourceId","Source","ctx","lookup","url","source","tiles","VITE_RASTER_API_KEY","devicePixelRatio","attribution","addSource","push","getSource","data","isSourceLoaded","setData","coords","coordinates","updateImage","setUrl","setTiles","src","removeLayer","removeSource","diff","newProps","prevProps","Set","acc","Layer","sourceId","addLayer","customLayer","find","layout","setLayoutProperty","validate","paint","setPaintProperty","minzoom","maxzoom","setLayerZoomRange","setFilter","visible","featureState","removeFeatureState","sourceLayer","setFeatureState","getLayer","Atmosphere","setFog","Terrain","isMapLibre","tileSize","setTerrain","exaggeration","Control","controlClasses","NavigationControl","ScaleControl","AttributionControl","GeolocateControl","FullscreenControl","ControlClass","custom","get","control","hasControl","removeControl","addControl","Marker","marker","popup","lngLat","ops","pops","mapboxgl","untrack","Popup","setHTML","onClose","setPopup","onDragStart","onDragEnd","onLngLatChange","getLngLat","toArray","setDraggable","draggable","setLngLat","addTo","openPopup","isOpen","togglePopup","trackPointer","closeOnClick","closeButton","focusAfterOpen","PATTERN","diagonal_l","size","path","diagonal_r","horizontal","vertical","cross","hash","chevron_h","chevron_v","square","fill","hex","circle","patternList","MGL_Image","setSize","width","height","hasImage","removeImage","pattern","pixelRatio","_loadImage","_createPattern","addImage","triggerRepaint","image","callback","trimStart","startsWith","DOMParser","parseFromString","childNodes","SVGElement","setAttribute","stroke","XMLSerializer","serializeToString","loadImage","error","imageData","trimEnd","endsWith","fetch","transform","img","Image","crossOrigin","onload","canvas","createElement","Math","max","getContext","imageSmoothingEnabled","drawImage","getImageData","Uint8Array","onAdd","this","willReadFrequently","render","fillStyle","background","fillRect","strokeStyle","color","lineWidth","lineWith","Path2D","easeQuad","in","x","out","inOut","pow","Camera","animationTime","isReverse","frame","translate","requestAnimationFrame","params","start","end","easing","alt","target","camera","getFreeCameraOptions","MercatorCoordinate","fromLngLat","lookAtPoint","setFreeCameraOptions","updateCameraPosition","lerp","a","b","t","_","idx","slerp","dotProduct","m","n","theta","acos","sin","loop","duration","rotateGlobe","secPerRev","maxSpinZoom","slowSpinZoom","distancePerSecond","reverse","easeTo","rotateViewport","around","onEnd","originalCenter","resetWhenStopped","resetNorthPitch","off","Light","setLight","Draw","draw","lib","getInstance","eventList","fn"],"mappings":"sWAIA,MAAOA,EAAOC,GAAYC,EAAY,CAClCC,IAAK,KACLC,iBAAiB,IAGRC,EAAaC,EAAc,CAACN,IAE5BO,EAAgBA,IAAMC,EAAWH,GAEjCI,EAGRC,IACDA,EAAMP,KAAOF,EAAS,MAAOS,EAAMP,KACnCO,EAAMN,iBAAmBH,EAAS,kBAAmBS,EAAMN,iBAE3DO,EACKN,EAAWO,SAAQ,CAACC,MAAO,CAACb,GAAMc,eAAA,OAC9BJ,EAAMI,QAAQ,KCsCrBC,EAAsB,CAC1B,cACA,YACA,cACA,aACA,cACA,eACA,eACA,aACA,UACA,aACA,gBACA,eACA,aACA,gBACA,UACA,WACA,WACA,cACA,cACA,SACA,YACA,cACA,SACA,YACA,cACA,SACA,YACA,gBACA,WACA,aACA,eACA,UACA,aACA,iBACA,eACA,kBACA,qBACA,yBACA,SACA,WACA,SACA,UACA,SACA,cACA,eACA,gBACA,qBACA,sBACA,uBAgCIC,EAAqB,CACzB,cACA,YACA,cACA,aACA,cACA,eACA,eACA,UACA,aACA,gBACA,eACA,aACA,iBAGIC,EAAoB,CACxB,WACA,WACA,YACA,cACA,WACA,oBACA,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,EAAMoP,UAAY,aAC3CpP,EAAMme,aAAene,EAAMme,YAAYF,GAGvC,MAAMG,EAAgD,CAAA,EAkBtD,OAjBA7d,EAAW4J,SAAQW,IACjB,GAAI9K,EAAM8K,GAAO,CACf,MAAMV,EAAS,QAAOU,EAAKG,MAAM,GAAGC,gBAC9BmT,EAAK/T,GAAOtK,EAAM8K,GAAMR,GAC9B8T,EAAUhU,GAASiU,EACnBrO,EAAIvQ,IAAI4K,GAAGD,EAAOiU,EACpB,KAIF9P,GAAU,KAERnD,OAAOC,KAAK+S,GAAWjU,SAAQC,GAAS4F,EAAIvQ,IAAIoe,IAAIzT,EAAOgU,EAAUhU,MAErE4F,EAAIvQ,KAAKyU,cAAc+J,EAAK,IAGvB,IAAI"}
1
+ {"version":3,"file":"index.js","sources":["../../src/components/MapProvider/index.tsx","../../src/events.ts","../../src/mapStyles.ts","../../src/components/MapGL/index.tsx","../../src/components/Source/index.tsx","../../src/components/Layer/index.tsx","../../src/components/Atmosphere/index.tsx","../../src/components/Terrain/index.tsx","../../src/components/Control/index.tsx","../../src/components/Marker/index.tsx","../../src/components/Popup/index.tsx","../../src/components/Image/index.tsx","../../src/components/Camera/index.tsx","../../src/components/Light/index.tsx","../../src/components/Draw/index.tsx"],"sourcesContent":["import { createContext, useContext, ParentComponent } from 'solid-js'\nimport { createStore } from 'solid-js/store'\nimport type { Map } from '../MapGL'\n\nconst [state, setState] = createStore({ map: null })\n\nexport const MapContext = createContext([state])\n\nexport const useMapContext = () => useContext(MapContext)\n\nexport const MapProvider: ParentComponent<{\n map?: Map\n}> = (props) => {\n props.map && setState('map', props.map)\n\n return (\n <MapContext.Provider value={[state]}>{props.children}</MapContext.Provider>\n )\n}\n","import type {\n MapMouseEvent,\n MapTouchEvent,\n MapWheelEvent,\n MapDataEvent,\n MapBoxZoomEvent,\n} from 'mapbox-gl'\n\ntype mapEventTypes = {\n onMouseDown?: (event: MapMouseEvent) => void\n onMouseUp?: (event: MapMouseEvent) => void\n onMouseOver?: (event: MapMouseEvent) => void\n onMouseOut?: (event: MapMouseEvent) => void\n onMouseMove?: (event: MapMouseEvent) => void\n onMouseEnter?: (event: MapMouseEvent) => void\n onMouseLeave?: (event: MapMouseEvent) => void\n onPreClick?: (event: MapMouseEvent) => void\n onClick?: (event: MapMouseEvent) => void\n onDblClick?: (event: MapMouseEvent) => void\n onContextMenu?: (event: MapMouseEvent) => void\n onTouchStart?: (event: MapTouchEvent) => void\n onTouchEnd?: (event: MapTouchEvent) => void\n onTouchCancel?: (event: MapTouchEvent) => void\n onTouchMove?: (event: MapTouchEvent) => void\n onWheel?: (event: MapWheelEvent) => void\n onResize?: () => void\n onRemove?: () => void\n onMoveStart?: (event: DragEvent) => void\n onMove?: (event: MapMouseEvent | MapTouchEvent) => void\n onMoveEnd?: (event: DragEvent) => void\n onDragStart?: (event: DragEvent) => void\n onDrag?: (event: MapMouseEvent | MapTouchEvent) => void\n onDragEnd?: (event: DragEvent) => void\n onZoomStart?: (event: MapMouseEvent | MapTouchEvent) => void\n onZoom?: (event: MapMouseEvent | MapTouchEvent) => void\n onZoomEnd?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotateStart?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotate?: (event: MapMouseEvent | MapTouchEvent) => void\n onRotatEnd?: (event: MapMouseEvent | MapTouchEvent) => void\n onPitchStart?: (event: MapDataEvent) => void\n onPitch?: (event: MapDataEvent) => void\n onPitchEnd?: (event: MapDataEvent) => void\n onBoxZoomStart?: (event: MapBoxZoomEvent) => void\n onBoxZoomEnd?: (event: MapBoxZoomEvent) => void\n onBoxZoomCancel?: (event: MapBoxZoomEvent) => void\n onWebglContextLost?: () => void\n onWebglContextRestored?: () => void\n onLoad?: (event: any) => void\n onRender?: () => void\n onIdle?: () => void\n onError?: (error: string) => void\n onData?: (event: MapDataEvent) => void\n onStyleData?: (event: MapDataEvent) => void\n onSourceData?: (event: MapDataEvent) => void\n onDataLoading?: (event: MapDataEvent) => void\n onStyleDataLoading?: (event: MapDataEvent) => void\n onSourceDataLoading?: (event: MapDataEvent) => void\n onStyleImageMissing?: (event: MapDataEvent) => void\n}\n\nconst mapEvents: string[] = [\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseOver',\n 'onMouseOut',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onPreClick',\n 'onClick',\n 'onDblClick',\n 'onContextMenu',\n 'onTouchStart',\n 'onTouchEnd',\n 'onTouchCancel',\n 'onWheel',\n 'onResize',\n 'onRemove',\n 'onTouchMove',\n 'onMoveStart',\n 'onMove',\n 'onMoveEnd',\n 'onDragStart',\n 'onDrag',\n 'onDragEnd',\n 'onZoomStart',\n 'onZoom',\n 'onZoomEnd',\n 'onRotateStart',\n 'onRotate',\n 'onRotatEnd',\n 'onPitchStart',\n 'onPitch',\n 'onPitchEnd',\n 'onBoxZoomStart',\n 'onBoxZoomEnd',\n 'onBoxZoomCancel',\n 'onWebglContextLost',\n 'onWebglContextRestored',\n 'onLoad',\n 'onRender',\n 'onIdle',\n 'onError',\n 'onData',\n 'onStyleData',\n 'onSourceData',\n 'onDataLoading',\n 'onStyleDataLoading',\n 'onSourceDataLoading',\n 'onStyleImageMissing',\n]\n\ntype layerEventTypes = {\n onMouseDown?: (event: MapMouseEvent) => void\n /** called when the mouse button is pressed down on the layer */\n onMouseUp?: (event: MapMouseEvent) => void\n /** called when the mouse button is released after a mouse down event on the layer */\n onMouseOver?: (event: MapMouseEvent) => void\n /** called when the mouse enters the layer */\n onMouseOut?: (event: MapMouseEvent) => void\n /** called when the mouse leaves the layer */\n onMouseMove?: (event: MapMouseEvent) => void\n /** called when the mouse is moved over the layer */\n onMouseEnter?: (event: MapMouseEvent) => void\n /** called when the mouse enters the layer */\n onMouseLeave?: (event: MapMouseEvent) => void\n /** called when the mouse leaves the layer */\n onClick?: (event: MapMouseEvent) => void\n /** called when the layer is clicked */\n onDblClick?: (event: MapMouseEvent) => void\n /** called when the layer is double-clicked */\n onContextMenu?: (event: MapMouseEvent) => void\n /** called when the context menu is triggered on the layer */\n onTouchStart?: (event: MapTouchEvent) => void\n /** called when a touch event is started on the layer */\n onTouchEnd?: (event: MapTouchEvent) => void\n /** called when a touch event is ended on the layer */\n onTouchCancel?: (event: MapTouchEvent) => void\n /** called when a touch event is cancelled on the layer */\n}\n\nconst layerEvents: any[] = [\n 'onMouseDown',\n 'onMouseUp',\n 'onMouseOver',\n 'onMouseOut',\n 'onMouseMove',\n 'onMouseEnter',\n 'onMouseLeave',\n 'onClick',\n 'onDblClick',\n 'onContextMenu',\n 'onTouchStart',\n 'onTouchEnd',\n 'onTouchCancel',\n]\n\nconst drawEvents: any[] = [\n 'onCreate',\n 'onDelete',\n 'onCombine',\n 'onUncombine',\n 'onUpdate',\n 'onSelectionchange',\n 'onModechange',\n 'onRender',\n 'onActionable',\n]\n\ntype drawEventTypes = {\n onCreate?: (event: Object) => void\n /** called when a feature is created */\n onDelete?: (event: Object) => void\n /** called when a feature is deleted */\n onCombine?: (event: Object) => void\n /** called when features are combined */\n onUncombine?: (event: Object) => void\n /** called when features are uncombined */\n onUpdate?: (event: Object) => void\n /** called when a feature is updated */\n onSelectionchange?: (event: Object) => void\n /** called when the selected features change */\n onModechange?: (event: Object) => void\n /** called when the draw mode changes */\n onRender?: (event: Object) => void\n /** called when the draw canvas is re-rendered */\n onActionable?: (event: Object) => void\n /** called when the state of the draw controls changes */\n}\n\nexport { mapEvents, layerEvents, drawEvents }\nexport type { mapEventTypes, layerEventTypes, drawEventTypes }\n","const mapBase = 'mapbox://styles/mapbox'\nconst gitBase = 'https://raw.githubusercontent.com/'\nconst gishub = 'https://raw.githubusercontent.com/GIShub4/map-styles/main/'\nconst hereBase = 'https://assets.vector.hereapi.com/styles/'\n\nexport const vectorStyleList: object = {\n mb: {\n light: `${mapBase}/light-v11`,\n dark: `${mapBase}/dark-v11`,\n street: `${mapBase}/streets-v12`,\n outdoor: `${mapBase}/outdoors-v12`,\n sat: `${mapBase}/satellite-v9`,\n sat_street: `${mapBase}/satellite-streets-v12`,\n nav: `${mapBase}/navigation-guidance-day-v4`,\n nav_night: `${mapBase}/navigation-guidance-night-v4`,\n basic: `${mapBase}/cjf4m44iw0uza2spb3q0a7s41`,\n monochrome: `${mapBase}/cjv6rzz4j3m4b1fqcchuxclhb`,\n leshine: `${mapBase}/cjcunv5ae262f2sm9tfwg8i0w`,\n icecream: `${mapBase}/cj7t3i5yj0unt2rmt3y4b5e32`,\n cali: `${mapBase}/cjerxnqt3cgvp2rmyuxbeqme7`,\n northstar: `${mapBase}/cj44mfrt20f082snokim4ungi`,\n mineral: `${mapBase}/cjtep62gq54l21frr1whf27ak`,\n moonlight: `${mapBase}/cj3kbeqzo00022smj7akz3o1e`,\n frank: `${mapBase}-map-design/ckshxkppe0gge18nz20i0nrwq`,\n minimo: `${mapBase}-map-design/cksjc2nsq1bg117pnekb655h1`,\n decimal: `${mapBase}-map-design/ck4014y110wt61ctt07egsel6`,\n standard: `${mapBase}-map-design/ckr0svm3922ki18qntevm857n`,\n blueprint: `${mapBase}-map-design/cks97e1e37nsd17nzg7p0308g`,\n bubble: `${mapBase}-map-design/cksysy2nl62zp17quosctdtcc`,\n pencil: `${mapBase}-map-design/cks9iema71es417mlrft4go2k`,\n swiss_ski: `${gitBase}mapbox/mapbox-gl-swiss-ski-style/master/cij1zoclj002y8rkkdjl69psd.json`,\n vintage: `${gitBase}mapbox/mapbox-gl-vintage-style/master/cif5p01n202nisaktvljx9mv3.json`,\n whaam: `${gitBase}mapbox/mapbox-gl-whaam-style/master/cii8323c8004w0nlvtss3dbm2.json`,\n neon: `${gitBase}NatEvatt/awesome-mapbox-gl-styles/master/styles/Neon/style.json`,\n camoflauge: `${gitBase}jingsam/mapbox-gl-styles/master/Camouflage.json`,\n emerald: `${gitBase}jingsam/mapbox-gl-styles/master/Emerald.json`,\n runner: `${gitBase}jingsam/mapbox-gl-styles/master/Runner.json`,\n x_ray: `${gitBase}jingsam/mapbox-gl-styles/master/X-ray.json`,\n },\n here: {\n base: `${hereBase}berlin/base/mapbox/tilezen?apikey={apikey}`,\n day: `${hereBase}berlin/day/mapbox/tilezen?apikey={apikey}`,\n night: `${hereBase}berlin/night/mapbox/tilezen?apikey={apikey}`,\n },\n esri: {\n blueprint: `${gishub}esri:blueprint.json`,\n charted_territory: `${gishub}esri:charted-territory.json`,\n colored_pencil: `${gishub}esri:colored-pencil.json`,\n community: `${gishub}esri:community.json`,\n mid_century: `${gishub}esri:mid-century.json`,\n modern_antique: `${gishub}esri:modern-antique.json`,\n nat_geo: `${gishub}esri:national-geographic.json`,\n newspaper: `${gishub}esri:newspaper.json`,\n open_street_map: `${gishub}esri:open-street-map.json`,\n light_gray_canvas: `${gishub}esri:light-gray-canvas.json`,\n dark_gray_canvas: `${gishub}esri:dark-gray-canvas.json`,\n human_geo_light: `${gishub}esri:human-geography-light.json`,\n human_geo_dark: `${gishub}esri:human-geography-dark.json`,\n world_navigation: `${gishub}esri:world-navigation.json`,\n world_street: `${gishub}esri:world-street.json`,\n world_street_night: `${gishub}esri:world-street-night.json`,\n world_terrain: `${gishub}esri:world-terrain.json`,\n world_terrain_hybrid: `${gishub}esri:world-terrain-hybrid.json`,\n world_topographic: `${gishub}esri:world-topographic.json`,\n chromium: `${gishub}esri:chromium.json`,\n dreamcatcher: `${gishub}esri:dreamcatcher.json`,\n seahaven: `${gishub}esri:seahaven.json`,\n sangria: `${gishub}esri:sangria.json`,\n mercurial: `${gishub}esri:mercurial.json`,\n imagery: `${gishub}esri:imagery.json`,\n imagery_hybrid: `${gishub}esri:imagery-hybrid.json`,\n firefly: `${gishub}esri:firefly.json`,\n firefly_hybrid: `${gishub}esri:firefly-hybrid.json`,\n oceans: `${gishub}esri:oceans.json`,\n },\n}\nconst carto = 'https://{s}.basemaps.cartocdn.com/rastertiles/'\nconst stamen = 'https://stamen-tiles-{s}.a.ssl.fastly.net/'\nconst tf = 'https://{s}.tile.thunderforest.com/'\n\nexport const rasterStyleList: object = {\n osm: {\n org: 'https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',\n human: 'https://{s}.tile.openstreetmap.fr/hot/{z}/{x}/{y}.png',\n cycle: 'https://{s}.tile-cyclosm.openstreetmap.fr/cyclosm/{z}/{x}/{y}.png',\n topo: 'https://{s}.tile.opentopomap.org/{z}/{x}/{y}.png',\n _copy:\n '<a href=\"https://www.openstreetmap.org/copyright\" target=\"_blank\">&copy; OpenStreetMap</a>',\n },\n carto: {\n voyager: `${carto}voyager_labels_under/{z}/{x}/{y}{r}.png`,\n positron: `${carto}light_all/{z}/{x}/{y}{r}.png`,\n dark: `${carto}dark_all/{z}/{x}/{y}{r}.png`,\n _copy:\n '<a href=\"https://carto.com/attribution\" target=\"_blank\">&copy; Carto</a>',\n },\n stamen: {\n toner: `${stamen}toner/{z}/{x}/{y}{r}.png`,\n toner_lite: `${stamen}toner-lite/{z}/{x}/{y}{r}.png`,\n watercolor: `${stamen}watercolor/{z}/{x}/{y}.png`,\n terrain: `${stamen}terrain/{z}/{x}/{y}{r}.png`,\n _copy:\n '<a href=\"https://stamen.com/privacy-policy\" target=\"_blank\">&copy; Stamen Design</a>',\n },\n tf: {\n cycle: `${tf}cycle/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n trans: `${tf}transport/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n trans_dark: `${tf}transport-dark/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n landscape: `${tf}landscape/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n outdoors: `${tf}outdoors/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n neighbourhood: `${tf}neighbourhood/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n spinal: `${tf}spinal-map/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n pioneer: `${tf}pioneer/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n atlas: `${tf}atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n mobile: `${tf}mobile-atlas/{z}/{x}/{y}{r}.png?apikey={apikey}`,\n _copy:\n '<a href=\"https://thunderforest.com/privacy\" target=\"_blank\">&copy; Thunderforest</a>',\n },\n}\n","import {\n createSignal,\n createEffect,\n onMount,\n onCleanup,\n Component,\n createUniqueId,\n on,\n} from 'solid-js'\nimport { MapProvider } from '../MapProvider'\nimport { mapEvents } from '../../events'\nimport { vectorStyleList } from '../../mapStyles'\nimport type { mapEventTypes } from '../../events'\nimport type mapboxgl from 'mapbox-gl'\nimport type { MapboxOptions } from 'mapbox-gl/src/ui/map'\nimport type { LngLatLike } from 'mapbox-gl/src/geo/lng_lat.js'\nimport type { LngLatBounds } from 'mapbox-gl/src/geo/lng_lat_bounds.js'\nimport type { PaddingOptions } from 'mapbox-gl/src/geo/edge_insets.js'\nimport type { StyleSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport type { JSX } from 'solid-js'\n\nexport type Map = mapboxgl.Map & {\n mapLib: any\n debug: boolean\n sourceIdList: string[]\n layerIdList: string[]\n}\n\nexport type Viewport = {\n id?: string\n point?: { x: number; y: number }\n center?: LngLatLike\n bounds?: LngLatBounds\n zoom?: number\n pitch?: number\n bearing?: number\n padding?: PaddingOptions\n inTransit?: boolean\n}\n\ntype Props = {\n /** ID for the map container element */\n id?: string\n /** Map Container CSS Style */\n style?: JSX.CSSProperties\n /** Map Container CSS Class */\n class?: string\n /** SolidJS Class List for Map Container */\n classList?: {\n [k: string]: boolean | undefined\n }\n /** Current Map View */\n viewport?: Viewport\n /** Mapbox Options\n * @see https://docs.mapbox.com/mapbox-gl-js/api/map/#map-parameters\n */\n options?: MapboxOptions\n /** Type for pan, move and zoom transitions */\n transitionType?: 'flyTo' | 'easeTo' | 'jumpTo'\n /** Event listener for Viewport updates */\n onViewportChange?: (viewport: Viewport) => void\n /** Event listener for User Interaction */\n onUserInteraction?: (user: boolean) => void\n /** Displays Map Tile Borders */\n showTileBoundaries?: boolean\n /** Displays Wireframe if Terrain is visible */\n showTerrainWireframe?: boolean\n /** Displays Borders if Padding is set */\n showPadding?: boolean\n /** Displays Label Collision Boxes */\n showCollisionBoxes?: boolean\n /** Displays all feature outlines even if normally not drawn by style rules */\n showOverdrawInspector?: boolean\n /** Mouse Cursor Style */\n cursorStyle?: string\n //** Dark Map Style */\n darkStyle?: StyleSpecification | string\n //** Disable automatic map resize */\n disableResize?: boolean\n //** MapLibre library */\n mapLib?: any\n //** APIkey for vector service */\n apikey?: string\n //** Debug Message Mode */\n debug?: boolean\n ref?: HTMLDivElement\n /** Children within the Map Container */\n children?: any\n} & mapEventTypes\n\n/** Creates a new Map Container */\nexport const MapGL: Component<Props> = (props) => {\n props.id ??= createUniqueId()\n\n let map: Map\n let mapRef: HTMLDivElement\n let resizeObserver: ResizeObserver\n let mutationObserver: MutationObserver\n\n const [mapLoaded, setMapLoaded] = createSignal(null)\n const [darkMode, setDarkMode] = createSignal(\n (typeof window !== 'undefined' &&\n window.matchMedia('(prefers-color-scheme: dark)').matches) ||\n (typeof document !== 'undefined' &&\n document.body.classList.contains('dark'))\n )\n const [internal, setInternal] = createSignal(false)\n\n const debug = (text, value?) => {\n props.debug &&\n console.debug('%c[MapGL]', 'color: #0ea5e9', text, value || '')\n }\n\n const getStyle = (light, dark) => {\n const style = darkMode() && dark ? dark : light\n return typeof style === 'string' || style instanceof String\n ? style\n ?.split(':')\n .reduce((p, c) => p && p[c], vectorStyleList)\n ?.replace(\n '{apikey}',\n //@ts-ignore\n props.apikey || import.meta.env.VITE_VECTOR_API_KEY\n ) || style\n : style || { version: 8, sources: {}, layers: [] }\n }\n\n onMount(async () => {\n let mapLib = props.mapLib || (await import('mapbox-gl'))\n if (!mapLib.Map) mapLib = window['maplibregl'] || window['mapboxgl']\n\n if (!mapLib.supported?.()) throw new Error('Mapbox GL not supported')\n\n debug(`Map (v${mapLib.version}) loading...`)\n map = new mapLib.Map({\n accessToken:\n //@ts-ignore\n props.options?.accessToken || import.meta.env.VITE_MAPBOX_ACCESS_TOKEN,\n interactive: props.options?.interactive || !!props.onViewportChange,\n ...props.options,\n ...props.viewport,\n projection: props.options?.projection,\n container: mapRef,\n style: getStyle(props.options?.style, props.darkStyle),\n fitBoundsOptions: { padding: props.viewport?.padding },\n } as MapboxOptions)\n\n map.mapLib = mapLib\n map.debug = props.debug\n map.sourceIdList = []\n map.layerIdList = []\n\n map.once('load', () => {\n setMapLoaded(map)\n debug('Map loaded')\n\n // Handle User Interaction\n ;['mousedown', 'touchstart', 'wheel'].forEach((event) =>\n map.on(event, (evt) => !evt.rotate && props.onUserInteraction(true))\n )\n ;['moveend', 'mouseup', 'touchend'].forEach((event) =>\n map.on(event, (evt) => !evt.rotate && props.onUserInteraction(false))\n )\n\n // Listen to dark theme changes\n const darkTheme =\n typeof window !== 'undefined' &&\n window?.matchMedia('(prefers-color-scheme: dark)')\n darkTheme?.addEventListener('change', () => {\n setDarkMode(darkTheme.matches)\n debug('Set dark theme to:', darkTheme.matches?.toString())\n })\n mutationObserver = new MutationObserver(() => {\n const darkTheme = document.body.classList.contains('dark')\n setDarkMode(darkTheme)\n debug('Set theme to:', darkTheme)\n })\n mutationObserver.observe(document.body, { attributes: true })\n\n // Listen to map container size changes\n // if (!props.disableResize) {\n // resizeObserver = new ResizeObserver(() => {\n // map?.resize()\n // debug('Map resized')\n // })\n // resizeObserver.observe(mapRef as Element)\n // }\n\n // Hook up events\n mapEvents.forEach((item) => {\n const prop = props[item]\n let isFirstMessage = true\n if (prop) {\n const event = item.slice(2).toLowerCase()\n if (typeof prop === 'function') {\n map.on(event, (e) => {\n prop(e)\n isFirstMessage && debug(`Map '${event}' event:`, e)\n isFirstMessage = false\n })\n } else {\n Object.keys(prop).forEach((layerId) => {\n map.on(event as any, layerId, (e) => {\n prop[layerId](e)\n isFirstMessage &&\n debug(`Map '${event}' event on '${layerId}':`, e)\n isFirstMessage = false\n })\n })\n }\n }\n })\n\n // Update Viewport\n map.on('move', (event) => {\n const viewport: Viewport = {\n ...props.viewport,\n id: props.id,\n // point: { x: event.originalEvent?.x, y: event.originalEvent?.y },\n center: props.viewport?.center?.lat\n ? map.getCenter()\n : [map.getCenter().lng, map.getCenter().lat],\n zoom: map.getZoom(),\n pitch: map.getPitch(),\n bearing: map.getBearing(),\n inTransit: true,\n }\n setInternal(true)\n !event.viewport && props.onViewportChange?.(viewport)\n })\n\n map.on('moveend', (event) => {\n !event.rotate &&\n props.onViewportChange?.({ ...props.viewport, inTransit: false })\n setInternal(false)\n })\n })\n })\n\n // Hook up viewport event\n createEffect(\n on(\n () => props.viewport,\n (vp) => {\n if (props.id !== vp?.id || internal()) return\n const viewport = {\n ...vp,\n ...(vp.bounds\n ? map.cameraForBounds(vp.bounds, {\n padding: vp?.padding,\n })\n : null),\n }\n map.stop()[props.transitionType || 'flyTo'](viewport)\n debug(`Update Viewport (${props.transitionType || 'flyTo'}):`, viewport)\n },\n { defer: true }\n )\n )\n\n // Update Projection\n createEffect(() => {\n const proj = props.options?.projection\n if (!map || !proj) return\n map.setProjection(proj)\n debug('Set Projection to:', proj)\n })\n\n // Update Cursor\n createEffect(() => {\n const cur = props.cursorStyle\n if (!map || !cur) return\n map.getCanvas().style.cursor = cur\n debug('Set Cursor to:', cur)\n })\n\n const insertLayers = (list, layers) => {\n layers.forEach((layer) => {\n const index = list.findIndex((i) =>\n layer.metadata.smg.beforeType\n ? i.type === layer.metadata.smg.beforeType\n : i.id === layer.metadata.smg.beforeId\n )\n list =\n index === -1\n ? [...list, layer]\n : [...list.slice(0, index), layer, ...list.slice(index + 1)]\n })\n return list\n }\n\n // Update map style\n createEffect((prev) => {\n const style = getStyle(props.options?.style, props.darkStyle)\n if (map?.isStyleLoaded() && prev !== style) {\n const oldStyle = map.getStyle()\n const oldLayers = oldStyle.layers.filter((l) =>\n map.layerIdList.includes(l.id)\n )\n const oldSources = Object.keys(oldStyle.sources)\n .filter((s) => map.sourceIdList.includes(s))\n .reduce((obj, key) => ({ ...obj, [key]: oldStyle.sources[key] }), {})\n\n map.setStyle(style)\n map.once('styledata', () => {\n if (!oldLayers) return\n const newStyle = map.getStyle()\n map.setStyle({\n ...newStyle,\n sources: { ...newStyle.sources, ...oldSources },\n layers: insertLayers(newStyle.layers, oldLayers),\n fog: oldStyle.fog,\n terrain: oldStyle.terrain,\n })\n debug('Set Mapstyle to:', style)\n })\n }\n return style\n }, props.options?.style)\n\n // Update debug features\n ;[\n 'showTileBoundaries',\n 'showTerrainWireframe',\n 'showCollisionBoxes',\n 'showPadding',\n 'showOverdrawInspector',\n ].forEach((item) => {\n createEffect(() => {\n const prop = props[item]\n if (!map || !prop) return\n map[item] = prop\n debug(`Set ${item} to:`, prop)\n })\n })\n\n onCleanup(() => {\n resizeObserver?.disconnect()\n mutationObserver?.disconnect()\n map?.remove()\n debug('Map removed')\n })\n\n return (\n <>\n <div\n ref={mapRef}\n id={props.id}\n class={props?.class}\n classList={props?.classList}\n style={\n props?.class || props?.classList\n ? null\n : props.style || {\n position: 'absolute',\n inset: 0,\n 'z-index': -1,\n }\n }\n />\n {mapLoaded() && (\n <MapProvider map={mapLoaded()}>{props.children}</MapProvider>\n )}\n </>\n )\n}\n","import {\n onCleanup,\n createEffect,\n Component,\n createContext,\n useContext,\n createUniqueId,\n} from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { SourceSpecification } from 'mapbox-gl/src/style-spec/types.js'\nimport { rasterStyleList } from '../../mapStyles'\n\nconst SourceContext = createContext<string>()\nexport const useSourceId = (): string => useContext(SourceContext)\n\ntype Props = {\n /** @optional Source ID for referencing non nexted Layers */\n id?: string\n /** @see https://docs.mapbox.com/mapbox-gl-js/style-spec/sources/ */\n source: SourceSpecification\n /** The map layers associated with this source */\n children?: any\n}\n\nexport const Source: Component<Props> = props => {\n const [ctx] = useMapContext()\n props.id ??= createUniqueId()\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #ec4899', text, value || '')\n }\n\n const lookup = url => {\n const s = url?.split(':').reduce((p, c) => p && p[c], rasterStyleList)\n const source = s\n ? {\n ...props.source,\n url: '',\n tiles: [\n s\n .replace(\n '{apikey}', //@ts-ignore\n props.source.apikey || import.meta.env.VITE_RASTER_API_KEY\n )\n .replace('{r}', window.devicePixelRatio > 1 ? '@2x' : ''),\n ],\n attribution: rasterStyleList[url.split(':')[0]]._copy,\n }\n : props.source\n\n source.tiles &&\n (source.tiles = ['a', 'b', 'c'].map(i =>\n source.tiles[0].replace('{s}', i)\n ))\n\n return source\n }\n\n // Add Source\n ctx.map.addSource(props.id, lookup(props.source.url))\n ctx.map.sourceIdList.push(props.id)\n debug('Add Source:', props.id)\n\n // Update Data\n const source = ctx.map.getSource(props.id)\n switch (props.source.type) {\n case 'geojson':\n createEffect(() => {\n const data = props.source.data\n if (!ctx.map.isSourceLoaded(props.id)) return\n source.setData(data || {})\n debug('Update GeoJSON Data:', props.id)\n })\n break\n case 'image':\n createEffect(() => {\n const url = props.source.url\n const coords = props.source.coordinates\n if (!ctx.map.isSourceLoaded(props.id)) return\n source.updateImage(url, coords)\n debug('Update Image Data:', props.id)\n })\n break\n case 'vector':\n createEffect(() => {\n const url = props.source.url\n const tiles = props.source.tiles\n if (!ctx.map.isSourceLoaded(props.id)) return\n url ? source.setUrl(url) : source.setTiles(tiles)\n debug('Update Vector Data:', props.id)\n })\n break\n case 'raster':\n createEffect(() => {\n const src = lookup(props.source.url)\n if (!ctx.map.isSourceLoaded(props.id)) return\n src.url ? source.setUrl(src.url) : source.setTiles(src.tiles)\n debug('Update Raster Data:', props.id)\n })\n break\n }\n\n // Remove Source\n onCleanup(() => {\n ctx.map\n ?.getStyle()\n .layers.forEach(\n layer => layer.source === props.id && ctx.map.removeLayer(layer.id)\n )\n ctx.map?.getSource(props.id) && ctx.map?.removeSource(props.id)\n debug('Remove Source:', props.id)\n })\n\n return (\n <SourceContext.Provider value={props.id}>\n {props.children}\n </SourceContext.Provider>\n )\n}\n","import { onCleanup, createEffect, Component, createUniqueId } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { useSourceId } from '../Source'\nimport { layerEvents } from '../../events'\nimport type { layerEventTypes } from '../../events'\nimport type {\n FilterSpecification,\n StyleSpecification,\n} from 'mapbox-gl/src/style-spec/types.js'\nimport type { CustomLayerInterface } from 'mapbox-gl/src/style/style_layer/custom_style_layer'\n\nconst diff = (\n newProps: StyleSpecification = {},\n prevProps: StyleSpecification = {}\n): [string, any][] => {\n const keys = new Set([...Object.keys(newProps), ...Object.keys(prevProps)])\n return [...keys].reduce((acc, key: string) => {\n const value = newProps[key]\n if (value !== prevProps[key]) {\n acc.push([key, value])\n }\n return acc\n }, [])\n}\n\ntype Props = {\n id?: string\n /** A string that uniquely identifies the layer. If not provided, a unique ID will be generated. */\n style?: StyleSpecification\n /** A Mapbox Style Specification object that defines the visual appearance of the layer. */\n customLayer?: CustomLayerInterface\n /** An object that implements the `CustomLayerInterface` interface, which allows you to create custom layers using WebGL. */\n filter?: FilterSpecification\n /** A Mapbox filter specification that defines which features of the layer to include or exclude from the layer. */\n visible?: boolean\n /** A boolean that determines whether the layer is visible or not. */\n sourceId?: string\n /** A string that specifies the ID of the source that the layer uses for its data. */\n beforeType?:\n | 'background'\n | 'fill'\n | 'line'\n | 'symbol'\n | 'raster'\n | 'circle'\n | 'fill-extrusion'\n | 'heatmap'\n | 'hillshade'\n | 'sky'\n /** A string that specifies the type of layer before which the current layer should be inserted. */\n beforeId?: string\n /** A string that specifies the ID of the layer before which the current layer should be inserted. */\n featureState?: { id: number | string; state: object }\n /** An object that specifies the state of a feature in the layer. The object consists of an ID (either a number or a string) and an object containing the state. */\n children?: any\n /** Any content that should be rendered within the layer. */\n} & layerEventTypes\n\nexport const Layer: Component<Props> = props => {\n const [ctx] = useMapContext()\n const sourceId: string = props.style?.source || useSourceId()\n props.id ??= createUniqueId()\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #10b981', text, value || '')\n }\n\n // Add Layer\n ctx.map.addLayer(\n props.customLayer || {\n ...props.style,\n id: props.id,\n source: sourceId,\n metadata: {\n smg: { beforeType: props.beforeType, beforeId: props.beforeId },\n },\n },\n props.beforeType\n ? ctx.map\n .getStyle()\n .layers.find(l => l.type === props.beforeType)?.id\n : props.beforeId\n )\n ctx.map.layerIdList.push(props.id)\n debug('Add Layer:', props.id)\n\n // Hook up events\n layerEvents.forEach(item => {\n if (props[item]) {\n const event = item.slice(2).toLowerCase()\n ctx.map.on(event, props.id, evt => {\n props[item](evt)\n debug(`Layer '${event}' event on '${props.id}':`, evt)\n })\n }\n })\n\n // Update Style\n createEffect((prev: StyleSpecification) => {\n const style = props.style\n if (style === prev) return\n\n if (style.layout !== prev?.layout)\n diff(style.layout, prev?.layout).forEach(([key, value]) =>\n ctx.map.setLayoutProperty(props.id, key, value, { validate: false })\n )\n\n if (style.paint !== prev?.paint)\n diff(style.paint, prev?.paint).forEach(([key, value]) =>\n ctx.map.setPaintProperty(props.id, key, value, { validate: false })\n )\n\n if (style.minzoom !== prev?.minzoom || style.maxzoom !== prev?.maxzoom)\n ctx.map.setLayerZoomRange(props.id, style.minzoom, style.maxzoom)\n\n if (style.filter !== prev?.filter)\n ctx.map.setFilter(props.id, style.filter, { validate: false })\n\n debug('Update Layer Style:', props.id)\n return style\n }, props.style)\n\n // Update Visibility\n createEffect((prev: boolean) => {\n if (props.visible === prev) return\n\n ctx.map.setLayoutProperty(\n props.id,\n 'visibility',\n props.visible ? 'visible' : 'none',\n { validate: false }\n )\n debug(`Update Visibility (${props.id}):`, props.visible)\n return props.visible\n }, props.visible)\n\n // Update Filter\n createEffect(async () => {\n if (!props.filter) return\n\n !ctx.map.isStyleLoaded() && (await ctx.map.once('styledata'))\n ctx.map.setFilter(props.id, props.filter)\n debug(`Update Filter (${props.id}):`, props.filter)\n })\n\n // Update Feature State\n createEffect(async () => {\n if (!props.featureState || props.featureState.id === null) return\n\n !ctx.map.isStyleLoaded() && (await ctx.map.once('styledata'))\n\n ctx.map.removeFeatureState({\n source: sourceId,\n sourceLayer: props.style['source-layer'],\n })\n ctx.map.setFeatureState(\n {\n source: sourceId,\n sourceLayer: props.style['source-layer'],\n id: props.featureState.id,\n },\n props.featureState.state\n )\n })\n\n //Remove Layer\n onCleanup(() => ctx.map?.getLayer(props.id) && ctx.map?.removeLayer(props.id))\n\n return props.children\n}\n","import { onCleanup, createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Fog } from 'mapbox-gl'\n\ntype Props = {\n /** Fog/Atmosphere Specifications */\n style?: Fog\n}\n\nexport const Atmosphere: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add or Update Atmosphere Layer\n createEffect(() => ctx.map.setFog(props.style || {}))\n\n // Remove Atmosphere Layer\n onCleanup(() => ctx.map.setFog(null))\n\n return null\n}\n","import { createEffect, VoidComponent, createUniqueId } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { useSourceId } from '../Source'\nimport type { TerrainSpecification } from 'mapbox-gl'\n\nexport const Terrain: VoidComponent<TerrainSpecification> = (props: TerrainSpecification) => {\n const [ctx] = useMapContext()\n let sourceId: string = useSourceId()\n\n // Add Terrain Source if not already defined\n if (!sourceId && !props.source) {\n sourceId = createUniqueId()\n ctx.map.addSource(sourceId,\n {\n type: 'raster-dem',\n url: ctx.map.isMapLibre\n ? 'https://demotiles.maplibre.org/terrain-tiles/tiles.json'\n : 'mapbox://mapbox.terrain-rgb',\n tileSize: ctx.map.isMapLibre ? 256 : 512,\n maxzoom: ctx.map.isMapLibre ? undefined : 14\n }\n )\n ctx.map.sourceIdList.push(sourceId)\n }\n\n // Add or Update Terrain Layer\n createEffect(() => {\n ctx.map.setTerrain({\n exaggeration: props.exaggeration || 1,\n source: props.source || sourceId,\n })\n })\n\n return null\n}\n","import { createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Options as AttributionOptions } from 'mapbox-gl/src/ui/control/attribution_control'\nimport type { Options as FullscreenOptions } from 'mapbox-gl/src/ui/control/fullscreen_control'\nimport type { Options as GeolocateOptions } from 'mapbox-gl/src/ui/control/geolocate_control'\nimport type { Options as NavigationOptions } from 'mapbox-gl/src/ui/control/navigation_control'\nimport type { Options as ScaleOptions } from 'mapbox-gl/src/ui/control/scale_control'\n\ntype ControlType = 'navigation' | 'scale' | 'attribution' | 'fullscreen' | 'geolocate'\n\ntype Props = {\n type?: ControlType\n /** a string that specifies the type of control to be displayed. It can be one of 'navigation', 'scale', 'attribution', 'fullscreen', or 'geolocate' */\n options?:\n | NavigationOptions\n | ScaleOptions\n | AttributionOptions\n | FullscreenOptions\n | GeolocateOptions\n | object\n /** an optional object that contains options specific to the control type */\n custom?: any\n /** an optional field that allows passing a custom control element. */\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n /** a string that specifies the position of the control on the map. It can be one of 'top-left', 'top-right', 'bottom-left', or 'bottom-right' */\n}\n\nexport const Control: VoidComponent<Props> = props => {\n const [ctx] = useMapContext()\n const controlClasses = new Map<ControlType, any>([\n ['navigation', ctx.map.mapLib.NavigationControl],\n ['scale', ctx.map.mapLib.ScaleControl],\n ['attribution', ctx.map.mapLib.AttributionControl],\n ['geolocate', ctx.map.mapLib.GeolocateControl],\n ['fullscreen', ctx.map.mapLib.FullscreenControl],\n ])\n const ControlClass = props.custom || controlClasses.get(props.type || 'navigation')\n if (!ControlClass) throw new Error(`Unknown control type: ${props.type}`)\n\n // Add or Update Control\n createEffect(() => {\n const control = new ControlClass(props.options)\n control && ctx.map.hasControl(control) && ctx.map.removeControl(control)\n ctx.map.addControl(control, props.position)\n })\n\n return null\n}\n","import { onCleanup, createEffect, Component, untrack } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type {\n Popup as PopupType,\n PopupOptions,\n Marker as MarkerType,\n MarkerOptions,\n LngLatLike\n} from 'mapbox-gl'\n\ntype Props = {\n /** Options for the Mapbox GL JS marker */\n options?: MarkerOptions & {\n /** Options for the Mapbox GL JS popup that is associated with the marker */\n popup: PopupOptions\n }\n /** The geographical location to place the marker */\n lngLat: LngLatLike\n /** Whether the marker's associated popup should be open */\n openPopup?: boolean\n /** Whether the marker is draggable */\n draggable?: boolean\n /** A function that is called when the marker is dragged to a new location */\n onLngLatChange?: (lngLat: number[]) => void\n /** A function that is called when the marker's associated popup is closed */\n onClose?: () => void\n /** A function that is called when the marker starts being dragged */\n onDragStart?: () => void\n /** A function that is called when the marker stops being dragged */\n onDragEnd?: () => void\n /** The content to be displayed in the marker's associated popup */\n children?: any\n}\n\nexport const Marker: Component<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n let marker: MarkerType = null\n let popup: PopupType = null\n\n if (!props.lngLat) throw new Error('Marker - lngLat is required')\n\n // Add or Update Marker\n createEffect(() => {\n const ops = { ...props.options }\n const pops = { ...props.options?.popup }\n if (!ctx.map) return\n const mapboxgl = ctx.map.mapLib\n untrack(() => {\n popup?.remove()\n popup = props.children\n ? new mapboxgl.Popup(pops)\n .setHTML(props.children)\n .on('close', () => props.onClose?.())\n : null\n\n marker?.remove()\n marker = new mapboxgl.Marker(ops)\n .setPopup(popup)\n .on('dragstart', () => props.onDragStart?.())\n .on('dragend', () => props.onDragEnd?.())\n .on('drag', () => props.onLngLatChange?.(marker.getLngLat().toArray()))\n .setDraggable(props.draggable || props.options?.draggable)\n .setLngLat(props.lngLat)\n .addTo(ctx.map)\n props.openPopup !== popup?.isOpen() && marker.togglePopup()\n })\n })\n\n // Toggle Popup\n createEffect(\n () => props.openPopup !== popup?.isOpen() && marker.togglePopup()\n )\n\n // Update Position\n createEffect(() => marker.setLngLat(props.lngLat))\n\n // Update Popup Content\n createEffect(() => popup?.setHTML(props.children))\n\n // Update Draggable\n createEffect(() => marker.setDraggable(props.draggable))\n\n // Remove Marker\n onCleanup(() => marker?.remove())\n\n return null\n}\n","import { onCleanup, createEffect, Component, untrack } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Popup as PopupType, PopupOptions, LngLatLike } from 'mapbox-gl'\n\ntype Props = {\n /** Options for configuring the popup */\n options?: PopupOptions\n /** Flag for tracking the mouse pointer */\n trackPointer?: boolean\n /** Longitude and latitude for the popup */\n lngLat?: LngLatLike\n /** Callback for when the popup is closed */\n onClose?: () => void\n /** Children to display within the popup */\n children?: any\n}\n\nexport const Popup: Component<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n let popup: PopupType = null\n\n if (!props.trackPointer && !props.lngLat)\n throw new Error('Popup - lngLat or trackPointer is required')\n\n // Add or Update Popup\n createEffect(() => {\n const ops = { ...props.options }\n if (!ctx.map) return\n const mapboxgl = ctx.map.mapLib\n untrack(() => {\n popup?.remove()\n popup = new mapboxgl.Popup(\n props.trackPointer\n ? { ...ops, closeOnClick: false, closeButton: false }\n : { focusAfterOpen: false, ...ops }\n )\n .setHTML(props.children || '')\n .setLngLat(props.lngLat)\n .on('close', () => props.onClose?.())\n .addTo(ctx.map)\n })\n })\n\n // Update Position\n createEffect(() =>\n props.trackPointer ? popup.trackPointer() : popup.setLngLat(props.lngLat)\n )\n\n // Update Content\n createEffect(() => popup.setHTML(props.children || ''))\n\n // Remove Popup\n onCleanup(() => popup?.remove())\n\n return null\n}\n","import {\n onCleanup,\n createSignal,\n createEffect,\n VoidComponent,\n untrack,\n} from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type {\n StyleImageInterface,\n StyleImageMetadata,\n} from 'mapbox-gl/src/style/style_image'\n\nconst PATTERN = {\n diagonal_l: { size: 20, path: 'M20 0 0 20M-10 10 10-10M10 30 30 10' },\n diagonal_r: { size: 20, path: 'M0 0 20 20M30 10 10-10M10 30-10 10' },\n horizontal: { size: 14, path: 'M7 0V20' },\n vertical: { size: 14, path: 'M0 7H20' },\n cross: { size: 18, path: 'M9 0V18M0 9H18' },\n hash: { size: 30, path: 'M15 0 30 15 15 30 0 15Z' },\n chevron_h: { size: 20, path: 'M-5 5 0 10 10 0 20 10 25 5M0 30 10 20 20 30' },\n chevron_v: { size: 20, path: 'M5-5 10 0 0 10 10 20 5 25M25 15 20 10 25 5' },\n square: { size: 20, path: 'M8 8H12V12H8Z', fill: true },\n hex: { size: 50, path: 'M0 0V50L50 25ZM50 0V50L0 25ZM25 0V50' },\n circle: {\n size: 25,\n path: 'M8 10A2.5 2.5 0 118.01 10M18 15A2.5 2.5 0 1018.01 15',\n fill: true,\n },\n}\n\nexport const patternList = Object.keys(PATTERN)\n\nexport type Color =\n | `#${string}`\n | `rgb(${number}, ${number}, ${number})`\n | `rgba(${number}, ${number}, ${number}, ${number})`\n | `hsl(${number}, ${number}%, ${number}%)`\n | `hsla(${number}, ${number}%, ${number}%, ${number})`\n\ntype Props = {\n id: string\n /** The unique identifier for the image. */\n source?:\n | HTMLImageElement\n | ImageBitmap\n | ImageData\n | SVGElement\n | { width: number; height: number; data: Uint8Array | Uint8ClampedArray }\n | StyleImageInterface\n | string\n /** The image to be used for the image component. */\n options?: StyleImageMetadata & {\n fill?: Color\n stroke?: Color\n transform?: string\n }\n /** The options for the image */\n pattern?: {\n type: string\n color: Color\n background: Color\n lineWith: number\n }\n /** The pattern to be used for the image component. */\n}\n\nexport const MGL_Image: VoidComponent<Props> = props => {\n const [ctx] = useMapContext()\n const [size, setSize] = createSignal({ width: 0, height: 0 })\n\n const debug = (text, value?) => {\n ctx.map.debug &&\n console.debug('%c[MapGL]', 'color: #10b981', text, value || '')\n }\n\n // Remove Image\n onCleanup(() => {\n ctx.map?.hasImage(props.id) && ctx.map?.removeImage(props.id)\n debug('Remove Image:', props.id)\n })\n\n // Add or Update Image\n createEffect(() => {\n if (!props.id) throw new Error('Image - ID is required')\n if (!props.source && !props.pattern)\n throw new Error('Image - Image or Pattern is required')\n\n const ops = props.pattern\n ? { pixelRatio: 2, ...props.options }\n : props.options\n\n _loadImage(props.source || _createPattern(props.pattern), data => {\n const { width, height } = data\n if (ctx.map && !ctx.map.hasImage(props.id))\n ctx.map.addImage(props.id, data, ops)\n if (\n !props.pattern &&\n untrack(() => width === size().width && height === size().height)\n ) {\n ctx.map.updateImage(props.id, data)\n ctx.map.triggerRepaint()\n } else {\n ctx.map.removeImage(props.id)\n ctx.map.addImage(props.id, data, ops)\n }\n setSize({ width, height })\n debug('Add Image:', props.id)\n ctx.map.on('style.load', () => {\n if (ctx.map.hasImage(props.id)) return\n ctx.map.addImage(props.id, data, ops)\n debug('Re-Add Image:', props.id)\n })\n })\n })\n\n // Load Image / SVG\n const _loadImage = (image, callback) => {\n if (typeof image == 'string' && image?.trimStart().startsWith('<svg')) {\n image = new DOMParser().parseFromString(image, 'image/svg+xml')\n .childNodes[0]\n }\n if (image instanceof SVGElement) {\n props.options?.fill && image.setAttribute('fill', props.options.fill)\n props.options?.stroke &&\n image.setAttribute('stroke', props.options.stroke)\n image = new XMLSerializer().serializeToString(image)\n }\n if (typeof image !== 'string') return callback(image)\n ctx.map.loadImage(image, async (error, imageData) => {\n if (error) {\n if (typeof image == 'string' && image?.trimEnd().endsWith('.svg')) {\n image = await (await fetch(image)).text()\n image = new DOMParser().parseFromString(image, 'image/svg+xml')\n .childNodes[0]\n image.setAttribute('fill', props.options.fill)\n image.setAttribute('stroke', props.options.stroke)\n image.setAttribute('transform', props.options.transform)\n image = new XMLSerializer().serializeToString(image)\n }\n const img = new Image()\n img.crossOrigin = 'Anonymous'\n img.onload = () => {\n const canvas = document.createElement('canvas')\n canvas.width = Math.max(img.width, 50)\n canvas.height = Math.max(img.height, 50)\n const ctx = canvas.getContext('2d')\n ctx.imageSmoothingEnabled = true\n ctx.drawImage(img, 0, 0, canvas.width, canvas.height)\n return callback(ctx.getImageData(0, 0, canvas.width, canvas.height))\n }\n img.src = image.trimStart().startsWith('<svg')\n ? 'data:image/svg+xml;charset=utf-8,' + image\n : image\n } else {\n return callback(imageData)\n }\n })\n }\n\n const _createPattern = pattern => {\n const p = PATTERN[pattern.type]\n return {\n width: p.size,\n height: p.size,\n data: new Uint8Array(p.size * p.size * 4),\n onAdd: function () {\n let canvas = document.createElement('canvas')\n canvas.width = canvas.height = p.size\n this.ctx = canvas.getContext('2d', { willReadFrequently: true })\n },\n render: function () {\n this.ctx.fillStyle = pattern.background || 'transparent'\n this.ctx.fillRect(0, 0, this.width, this.height)\n this.ctx.strokeStyle = this.ctx.fillStyle = pattern.color || 'black'\n this.ctx.lineWidth = pattern.lineWith || 1\n this.ctx.stroke(new Path2D(p.path))\n if (p.fill) this.ctx.fill(new Path2D(p.path))\n this.data = this.ctx.getImageData(0, 0, this.width, this.height).data\n return true\n },\n }\n }\n\n return null\n}\n","import { createEffect, Component, onCleanup, createSignal } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { LngLatLike } from 'mapbox-gl'\n\n// linearly interpolate between two positions [x,y,z] based on time\nconst lerp = (a: number[], b: number[], t: number): number[] =>\n a.map((_, idx) => (1.0 - t) * a[idx] + t * b[idx])\n\n// sphericaly interpolate between two positions [x,y,z] based on time\nconst slerp = (a: number[], b: number[], t: number): number[] => {\n const dotProduct = a.map((_, idx) => a[idx] * b[idx]).reduce((m, n) => m + n)\n const theta = Math.acos(dotProduct)\n\n return a.map(\n (_, idx) =>\n (Math.sin((1 - t) * theta) / Math.sin(theta)) * a[idx] +\n (Math.sin(t * theta) / Math.sin(theta)) * b[idx]\n )\n}\n\n// calculations from: https://easings.net\nconst easeQuad = {\n in: (x: number): number => x * x,\n out: (x: number): number => 1 - (1 - x) * (1 - x),\n inOut: (x: number): number =>\n x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,\n}\n\n/** Options for rotating the globe. */\ninterface RotateGlobeOptions {\n /** The number of seconds per revolution. */\n secPerRev?: number\n /** The maximum zoom level for spinning the globe. */\n maxSpinZoom?: number\n /** The zoom level at which the spinning slows down. */\n slowSpinZoom?: number\n}\n\n/** Options for rotating the viewport. */\ninterface RotateViewportOptions {\n /** The number of seconds per revolution. */\n secPerRev?: number\n /** The pitch angle in degrees. */\n pitch?: number\n /** The center of rotation. */\n around?: LngLatLike\n}\n\n/** Props for the component. */\ntype Props = {\n /** Whether to rotate the globe. */\n rotateGlobe?: boolean | RotateGlobeOptions\n /** Whether to rotate the viewport. */\n rotateViewport?: boolean | RotateViewportOptions\n /** Whether to reverse the rotation direction. */\n reverse?: boolean\n /** Whether to reset the rotation when stopped. */\n resetWhenStopped?: boolean\n /** Translation options. */\n translate?: {\n /** The type of translation. */\n type?: 'line' | 'sphere'\n /** The starting position. */\n start: [number, number, number]\n /** The ending position. */\n end: [number, number, number]\n /** The target position. */\n target: LngLatLike\n /** The ending target position. */\n targetEnd?: LngLatLike\n /** The easing function to use. */\n easing?: 'in' | 'out' | 'inOut'\n /** Whether to loop the translation. */\n loop?: boolean\n /** The duration of the translation in milliseconds. */\n duration: number\n }\n /** The children to render. */\n children?: any\n}\n\nexport const Camera: Component<Props> = (props) => {\n const [ctx] = useMapContext()\n let animationTime = 0.1\n let isReverse = false\n\n // Handle User Interaction\n const [userInteraction, setUserInteraction] = createSignal(false)\n ;['mousedown', 'touchstart', 'wheel'].forEach((event) =>\n ctx.map.on(event, (evt) => !evt.rotate && setUserInteraction(true))\n )\n ;['moveend', 'mouseup', 'touchend'].forEach((event) =>\n ctx.map.on(event, (evt) => !evt.rotate && setUserInteraction(false))\n )\n\n const updateCameraPosition = async (\n [lng, lat, alt]: number[],\n target: LngLatLike\n ) => {\n const camera = ctx.map.getFreeCameraOptions()\n camera.position = ctx.map.mapLib.MercatorCoordinate.fromLngLat(\n [lng, lat],\n alt\n )\n camera.lookAtPoint(target)\n ctx.map.setFreeCameraOptions(camera)\n }\n\n const frame = () => {\n props.translate && window.requestAnimationFrame(frame)\n const params = [\n props.translate.start,\n props.translate.end,\n props.translate.easing\n ? easeQuad[props.translate.easing](animationTime)\n : animationTime,\n ] as const\n const position =\n props.translate.type === 'line' ? lerp(...params) : slerp(...params)\n\n updateCameraPosition(position, props.translate.target)\n\n if (!props.translate.loop && (animationTime > 1.0 || animationTime < 0.0))\n isReverse = !isReverse\n animationTime = isReverse ? animationTime - 0.001 : animationTime + 0.001\n }\n\n createEffect(() => {\n props.translate && window.requestAnimationFrame(frame)\n })\n\n const options = { duration: 1000, easing: (n) => n }\n\n const rotateGlobe = (): void => {\n if (userInteraction()) return\n const {\n secPerRev = 120,\n maxSpinZoom = 5,\n slowSpinZoom = 3,\n }: RotateGlobeOptions = props.rotateGlobe as RotateGlobeOptions\n\n const zoom: number = ctx.map.getZoom()\n if (zoom > maxSpinZoom) return\n let distancePerSecond: number = 360 / secPerRev\n if (zoom > slowSpinZoom)\n distancePerSecond *= (maxSpinZoom - zoom) / (maxSpinZoom - slowSpinZoom)\n const center: mapboxgl.LngLat = ctx.map.getCenter()\n center.lng = props.reverse\n ? center.lng + distancePerSecond\n : center.lng - distancePerSecond\n ctx.map.easeTo({ center, ...options }, { rotate: true })\n }\n\n const rotateViewport = (): void => {\n if (!props.rotateViewport || userInteraction()) return\n const rotateViewport = props.rotateViewport as RotateViewportOptions\n const secPerRev = rotateViewport?.secPerRev || 60\n const bearing = props.reverse\n ? ctx.map.getBearing() + 360 / secPerRev\n : ctx.map.getBearing() - 360 / secPerRev\n const pitch = rotateViewport?.pitch || 60\n const around = rotateViewport?.around\n ctx.map.easeTo({ bearing, pitch, around, ...options }, { rotate: true })\n }\n\n const onEnd = () => (props.rotateGlobe ? rotateGlobe() : rotateViewport())\n ctx.map.on('moveend', onEnd).on('dragend', onEnd)\n\n let originalCenter: mapboxgl.LngLatLike\n createEffect(() => {\n if (props.rotateGlobe == undefined) return\n if (props.rotateGlobe) {\n originalCenter = ctx.map.getCenter()\n rotateGlobe()\n } else {\n props.resetWhenStopped\n ? ctx.map.stop().easeTo({ center: originalCenter })\n : ctx.map.stop()\n }\n })\n\n createEffect(() => {\n if (props.rotateViewport == undefined) return\n props.rotateViewport\n ? rotateViewport()\n : props.resetWhenStopped\n ? ctx.map.stop().resetNorthPitch()\n : ctx.map.stop()\n })\n\n onCleanup(() => ctx.map.off('moveend', onEnd).off('dragend', onEnd))\n\n return props.children\n}\n","import { onCleanup, createEffect, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport type { Light as LightSpecification } from 'mapbox-gl'\n\ntype Props = {\n /** Light Specifications */\n style: LightSpecification\n}\nexport const Light: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add or Update Light Layer\n createEffect(() => ctx.map.setLight(props.style || {}))\n\n // Remove Light Layer\n onCleanup(() => ctx.map?.setLight(null))\n\n return null\n}\n","import { onCleanup, VoidComponent } from 'solid-js'\nimport { useMapContext } from '../MapProvider'\nimport { drawEvents } from '../../events'\nimport type { drawEventTypes } from '../../events'\n\ntype Props = {\n /** Draw Library */\n lib: any\n /** Draw Options */\n options?: object\n /** Draw Control Position */\n position?: 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right'\n /** Draw Control Instance */\n getInstance?: (object) => void\n} & drawEventTypes\n\nexport const Draw: VoidComponent<Props> = (props: Props) => {\n const [ctx] = useMapContext()\n\n // Add Draw Control\n const draw = new props.lib(props.options)\n ctx.map.addControl(draw, props.position || 'top-right')\n props.getInstance && props.getInstance(draw)\n\n // Hook up events\n const eventList: Record<string, (evt: any) => void> = {}\n drawEvents.forEach(item => {\n if (props[item]) {\n const event = `draw.${item.slice(2).toLowerCase()}`\n const fn = evt => props[item](evt)\n eventList[event] = fn\n ctx.map.on(event, fn)\n }\n })\n\n // Remove Draw Control\n onCleanup(() => {\n // Remove Events\n Object.keys(eventList).forEach(event => ctx.map.off(event, eventList[event]))\n // Remove Control\n ctx.map?.removeControl(draw)\n })\n\n return null\n}\n"],"names":["state","setState","createStore","map","MapContext","createContext","useMapContext","useContext","MapProvider","props","_$createComponent","Provider","value","children","mapEvents","layerEvents","drawEvents","mapBase","gitBase","gishub","hereBase","vectorStyleList","mb","light","dark","street","outdoor","sat","sat_street","nav","nav_night","basic","monochrome","leshine","icecream","cali","northstar","mineral","moonlight","frank","minimo","decimal","standard","blueprint","bubble","pencil","swiss_ski","vintage","whaam","neon","camoflauge","emerald","runner","x_ray","here","base","day","night","esri","charted_territory","colored_pencil","community","mid_century","modern_antique","nat_geo","newspaper","open_street_map","light_gray_canvas","dark_gray_canvas","human_geo_light","human_geo_dark","world_navigation","world_street","world_street_night","world_terrain","world_terrain_hybrid","world_topographic","chromium","dreamcatcher","seahaven","sangria","mercurial","imagery","imagery_hybrid","firefly","firefly_hybrid","oceans","carto","stamen","tf","rasterStyleList","osm","org","human","cycle","topo","_copy","voyager","positron","toner","toner_lite","watercolor","terrain","trans","trans_dark","landscape","outdoors","neighbourhood","spinal","pioneer","atlas","mobile","MapGL","mapRef","mutationObserver","id","createUniqueId","mapLoaded","setMapLoaded","createSignal","darkMode","setDarkMode","window","matchMedia","matches","document","body","classList","contains","internal","setInternal","debug","text","console","getStyle","style","String","split","reduce","p","c","replace","apikey","env","VITE_VECTOR_API_KEY","version","sources","layers","onMount","async","mapLib","import","Map","supported","Error","accessToken","options","VITE_MAPBOX_ACCESS_TOKEN","interactive","onViewportChange","viewport","projection","container","darkStyle","fitBoundsOptions","padding","sourceIdList","layerIdList","once","forEach","event","on","evt","rotate","onUserInteraction","darkTheme","addEventListener","toString","MutationObserver","observe","attributes","item","prop","isFirstMessage","slice","toLowerCase","e","Object","keys","layerId","center","lat","getCenter","lng","zoom","getZoom","pitch","getPitch","bearing","getBearing","inTransit","createEffect","vp","bounds","cameraForBounds","stop","transitionType","defer","proj","setProjection","cur","cursorStyle","getCanvas","cursor","prev","isStyleLoaded","oldStyle","oldLayers","filter","l","includes","oldSources","s","obj","key","setStyle","newStyle","insertLayers","list","layer","index","findIndex","i","metadata","smg","beforeType","type","beforeId","fog","onCleanup","disconnect","remove","_el$","_tmpl$","_$use","_$effect","_p$","_v$","_v$2","class","_v$3","_v$4","position","inset","_$setAttribute","_$className","_$classList","_$style","undefined","_$memo","_c$","SourceContext","useSourceId","Source","ctx","lookup","url","source","tiles","VITE_RASTER_API_KEY","devicePixelRatio","attribution","addSource","push","getSource","data","isSourceLoaded","setData","coords","coordinates","updateImage","setUrl","setTiles","src","removeLayer","removeSource","diff","newProps","prevProps","Set","acc","Layer","sourceId","addLayer","customLayer","find","layout","setLayoutProperty","validate","paint","setPaintProperty","minzoom","maxzoom","setLayerZoomRange","setFilter","visible","featureState","removeFeatureState","sourceLayer","setFeatureState","getLayer","Atmosphere","setFog","Terrain","isMapLibre","tileSize","setTerrain","exaggeration","Control","controlClasses","NavigationControl","ScaleControl","AttributionControl","GeolocateControl","FullscreenControl","ControlClass","custom","get","control","hasControl","removeControl","addControl","Marker","marker","popup","lngLat","ops","pops","mapboxgl","untrack","Popup","setHTML","onClose","setPopup","onDragStart","onDragEnd","onLngLatChange","getLngLat","toArray","setDraggable","draggable","setLngLat","addTo","openPopup","isOpen","togglePopup","trackPointer","closeOnClick","closeButton","focusAfterOpen","PATTERN","diagonal_l","size","path","diagonal_r","horizontal","vertical","cross","hash","chevron_h","chevron_v","square","fill","hex","circle","patternList","MGL_Image","setSize","width","height","hasImage","removeImage","pattern","pixelRatio","_loadImage","_createPattern","addImage","triggerRepaint","image","callback","trimStart","startsWith","DOMParser","parseFromString","childNodes","SVGElement","setAttribute","stroke","XMLSerializer","serializeToString","loadImage","error","imageData","trimEnd","endsWith","fetch","transform","img","Image","crossOrigin","onload","canvas","createElement","Math","max","getContext","imageSmoothingEnabled","drawImage","getImageData","Uint8Array","onAdd","this","willReadFrequently","render","fillStyle","background","fillRect","strokeStyle","color","lineWidth","lineWith","Path2D","easeQuad","in","x","out","inOut","pow","Camera","animationTime","isReverse","userInteraction","setUserInteraction","frame","translate","requestAnimationFrame","params","start","end","easing","alt","target","camera","getFreeCameraOptions","MercatorCoordinate","fromLngLat","lookAtPoint","setFreeCameraOptions","updateCameraPosition","lerp","a","b","t","_","idx","slerp","dotProduct","m","n","theta","acos","sin","loop","duration","rotateGlobe","secPerRev","maxSpinZoom","slowSpinZoom","distancePerSecond","reverse","easeTo","rotateViewport","around","onEnd","originalCenter","resetWhenStopped","resetNorthPitch","off","Light","setLight","Draw","draw","lib","getInstance","eventList","fn"],"mappings":"sWAIA,MAAOA,EAAOC,GAAYC,EAAY,CAAEC,IAAK,OAEhCC,EAAaC,EAAc,CAACL,I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2
  import { useMapContext } from '../MapProvider';
3
3
  // linearly interpolate between two positions [x,y,z] based on time
4
4
  const lerp = (a, b, t) => a.map((_, idx) => (1.0 - t) * a[idx] + t * b[idx]);
@@ -15,12 +15,14 @@ const easeQuad = {
15
15
  out: (x) => 1 - (1 - x) * (1 - x),
16
16
  inOut: (x) => x < 0.5 ? 2 * x * x : 1 - Math.pow(-2 * x + 2, 2) / 2,
17
17
  };
18
- export const Camera = props => {
18
+ export const Camera = (props) => {
19
19
  const [ctx] = useMapContext();
20
- if (!ctx.map)
21
- return null;
22
20
  let animationTime = 0.1;
23
21
  let isReverse = false;
22
+ // Handle User Interaction
23
+ const [userInteraction, setUserInteraction] = createSignal(false);
24
+ ['mousedown', 'touchstart', 'wheel'].forEach((event) => ctx.map.on(event, (evt) => !evt.rotate && setUserInteraction(true)));
25
+ ['moveend', 'mouseup', 'touchend'].forEach((event) => ctx.map.on(event, (evt) => !evt.rotate && setUserInteraction(false)));
24
26
  const updateCameraPosition = async ([lng, lat, alt], target) => {
25
27
  const camera = ctx.map.getFreeCameraOptions();
26
28
  camera.position = ctx.map.mapLib.MercatorCoordinate.fromLngLat([lng, lat], alt);
@@ -45,9 +47,9 @@ export const Camera = props => {
45
47
  createEffect(() => {
46
48
  props.translate && window.requestAnimationFrame(frame);
47
49
  });
48
- const options = { duration: 1000, easing: n => n };
50
+ const options = { duration: 1000, easing: (n) => n };
49
51
  const rotateGlobe = () => {
50
- if (ctx.userInteraction)
52
+ if (userInteraction())
51
53
  return;
52
54
  const { secPerRev = 120, maxSpinZoom = 5, slowSpinZoom = 3, } = props.rotateGlobe;
53
55
  const zoom = ctx.map.getZoom();
@@ -63,7 +65,7 @@ export const Camera = props => {
63
65
  ctx.map.easeTo({ center, ...options }, { rotate: true });
64
66
  };
65
67
  const rotateViewport = () => {
66
- if (!props.rotateViewport || ctx.userInteraction)
68
+ if (!props.rotateViewport || userInteraction())
67
69
  return;
68
70
  const rotateViewport = props.rotateViewport;
69
71
  const secPerRev = rotateViewport?.secPerRev || 60;
@@ -3,7 +3,7 @@ import { MapProvider } from '../MapProvider';
3
3
  import { mapEvents } from '../../events';
4
4
  import { vectorStyleList } from '../../mapStyles';
5
5
  /** Creates a new Map Container */
6
- export const MapGL = props => {
6
+ export const MapGL = (props) => {
7
7
  props.id ??= createUniqueId();
8
8
  let map;
9
9
  let mapRef;
@@ -14,10 +14,7 @@ export const MapGL = props => {
14
14
  window.matchMedia('(prefers-color-scheme: dark)').matches) ||
15
15
  (typeof document !== 'undefined' &&
16
16
  document.body.classList.contains('dark')));
17
- const [userInteraction, setUserInteraction] = createSignal(false);
18
17
  const [internal, setInternal] = createSignal(false);
19
- // debounce user interactions
20
- createEffect(() => props.onUserInteraction?.(userInteraction()));
21
18
  const debug = (text, value) => {
22
19
  props.debug &&
23
20
  console.debug('%c[MapGL]', 'color: #0ea5e9', text, value || '');
@@ -59,8 +56,8 @@ export const MapGL = props => {
59
56
  map.once('load', () => {
60
57
  setMapLoaded(map);
61
58
  debug('Map loaded');
62
- ['mousedown', 'touchstart', 'wheel'].forEach(event => map.on(event, evt => !evt.rotate && setUserInteraction(true)));
63
- ['moveend', 'mouseup', 'touchend'].forEach(event => map.on(event, evt => !evt.rotate && setUserInteraction(false)));
59
+ ['mousedown', 'touchstart', 'wheel'].forEach((event) => map.on(event, (evt) => !evt.rotate && props.onUserInteraction(true)));
60
+ ['moveend', 'mouseup', 'touchend'].forEach((event) => map.on(event, (evt) => !evt.rotate && props.onUserInteraction(false)));
64
61
  // Listen to dark theme changes
65
62
  const darkTheme = typeof window !== 'undefined' &&
66
63
  window?.matchMedia('(prefers-color-scheme: dark)');
@@ -83,21 +80,21 @@ export const MapGL = props => {
83
80
  // resizeObserver.observe(mapRef as Element)
84
81
  // }
85
82
  // Hook up events
86
- mapEvents.forEach(item => {
83
+ mapEvents.forEach((item) => {
87
84
  const prop = props[item];
88
85
  let isFirstMessage = true;
89
86
  if (prop) {
90
87
  const event = item.slice(2).toLowerCase();
91
88
  if (typeof prop === 'function') {
92
- map.on(event, e => {
89
+ map.on(event, (e) => {
93
90
  prop(e);
94
91
  isFirstMessage && debug(`Map '${event}' event:`, e);
95
92
  isFirstMessage = false;
96
93
  });
97
94
  }
98
95
  else {
99
- Object.keys(prop).forEach(layerId => {
100
- map.on(event, layerId, e => {
96
+ Object.keys(prop).forEach((layerId) => {
97
+ map.on(event, layerId, (e) => {
101
98
  prop[layerId](e);
102
99
  isFirstMessage &&
103
100
  debug(`Map '${event}' event on '${layerId}':`, e);
@@ -108,7 +105,7 @@ export const MapGL = props => {
108
105
  }
109
106
  });
110
107
  // Update Viewport
111
- map.on('move', event => {
108
+ map.on('move', (event) => {
112
109
  const viewport = {
113
110
  ...props.viewport,
114
111
  id: props.id,
@@ -124,7 +121,7 @@ export const MapGL = props => {
124
121
  setInternal(true);
125
122
  !event.viewport && props.onViewportChange?.(viewport);
126
123
  });
127
- map.on('moveend', event => {
124
+ map.on('moveend', (event) => {
128
125
  !event.rotate &&
129
126
  props.onViewportChange?.({ ...props.viewport, inTransit: false });
130
127
  setInternal(false);
@@ -132,7 +129,7 @@ export const MapGL = props => {
132
129
  });
133
130
  });
134
131
  // Hook up viewport event
135
- createEffect(on(() => props.viewport, vp => {
132
+ createEffect(on(() => props.viewport, (vp) => {
136
133
  if (props.id !== vp?.id || internal())
137
134
  return;
138
135
  const viewport = {
@@ -163,8 +160,8 @@ export const MapGL = props => {
163
160
  debug('Set Cursor to:', cur);
164
161
  });
165
162
  const insertLayers = (list, layers) => {
166
- layers.forEach(layer => {
167
- const index = list.findIndex(i => layer.metadata.smg.beforeType
163
+ layers.forEach((layer) => {
164
+ const index = list.findIndex((i) => layer.metadata.smg.beforeType
168
165
  ? i.type === layer.metadata.smg.beforeType
169
166
  : i.id === layer.metadata.smg.beforeId);
170
167
  list =
@@ -175,13 +172,13 @@ export const MapGL = props => {
175
172
  return list;
176
173
  };
177
174
  // Update map style
178
- createEffect(prev => {
175
+ createEffect((prev) => {
179
176
  const style = getStyle(props.options?.style, props.darkStyle);
180
177
  if (map?.isStyleLoaded() && prev !== style) {
181
178
  const oldStyle = map.getStyle();
182
- const oldLayers = oldStyle.layers.filter(l => map.layerIdList.includes(l.id));
179
+ const oldLayers = oldStyle.layers.filter((l) => map.layerIdList.includes(l.id));
183
180
  const oldSources = Object.keys(oldStyle.sources)
184
- .filter(s => map.sourceIdList.includes(s))
181
+ .filter((s) => map.sourceIdList.includes(s))
185
182
  .reduce((obj, key) => ({ ...obj, [key]: oldStyle.sources[key] }), {});
186
183
  map.setStyle(style);
187
184
  map.once('styledata', () => {
@@ -206,7 +203,7 @@ export const MapGL = props => {
206
203
  'showCollisionBoxes',
207
204
  'showPadding',
208
205
  'showOverdrawInspector',
209
- ].forEach(item => {
206
+ ].forEach((item) => {
210
207
  createEffect(() => {
211
208
  const prop = props[item];
212
209
  if (!map || !prop)
@@ -229,9 +226,6 @@ export const MapGL = props => {
229
226
  inset: 0,
230
227
  'z-index': -1,
231
228
  }}/>
232
- {mapLoaded() &&
233
- <MapProvider map={mapLoaded()}>
234
- {props.children}
235
- </MapProvider>}
229
+ {mapLoaded() && (<MapProvider map={mapLoaded()}>{props.children}</MapProvider>)}
236
230
  </>);
237
231
  };
@@ -1,15 +1,9 @@
1
- import { createContext, useContext } from "solid-js";
2
- import { createStore } from "solid-js/store";
3
- const [state, setState] = createStore({
4
- map: null,
5
- userInteraction: false
6
- });
1
+ import { createContext, useContext } from 'solid-js';
2
+ import { createStore } from 'solid-js/store';
3
+ const [state, setState] = createStore({ map: null });
7
4
  export const MapContext = createContext([state]);
8
5
  export const useMapContext = () => useContext(MapContext);
9
- export const MapProvider = props => {
6
+ export const MapProvider = (props) => {
10
7
  props.map && setState('map', props.map);
11
- props.userInteraction && setState('userInteraction', props.userInteraction);
12
- return (<MapContext.Provider value={[state]}>
13
- {props.children}
14
- </MapContext.Provider>);
8
+ return (<MapContext.Provider value={[state]}>{props.children}</MapContext.Provider>);
15
9
  };
@@ -1,14 +1,11 @@
1
- import { ParentComponent } from "solid-js";
1
+ import { ParentComponent } from 'solid-js';
2
2
  import type { Map } from '../MapGL';
3
3
  export declare const MapContext: import("solid-js").Context<{
4
4
  map: any;
5
- userInteraction: boolean;
6
5
  }[]>;
7
6
  export declare const useMapContext: () => {
8
7
  map: any;
9
- userInteraction: boolean;
10
8
  }[];
11
9
  export declare const MapProvider: ParentComponent<{
12
10
  map?: Map;
13
- userInteraction?: boolean;
14
11
  }>;
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "1.8.1",
2
+ "version": "1.8.2",
3
3
  "name": "solid-map-gl",
4
4
  "description": "Solid Component Library for Mapbox GL JS",
5
5
  "info": "Solid Component Library for Mapbox GL JS. Mapbox GL JS is a JavaScript library that renders interactive maps from vector tiles and Mapbox styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.",