Solid Map GL provides Mapbox & MapLibre functionality within SolidJS applications
Translation pending
Developer toolsTypeScript · JavaScriptGitHub @GIShub4OnlineOwner unconfirmed
Have you tried it? One tap is enough. No sign-in needed.
SolidJS Component Library for Mapbox GL JS & MapLibre GL JS 🌏
Translation pending
Taken from the repository README
Loading the full README. The saved excerpt is shown below.
SolidJS Component Library for Mapbox GL & MapLibre GL
SolidJS Component Library for Mapbox GL JS and MapLibre GL. Both libraries render interactive maps from vector tiles and Map styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.Read the full README ↗SolidJS Component Library for Mapbox GL JS and MapLibre GL. Both libraries render interactive maps from vector tiles and Map styles using WebGL. This project is intended to be as close as possible to the Mapbox GL JS API.
pnpm add mapbox-gl solid-map-gl
yarn add mapbox-gl solid-map-gl
npm i mapbox-gl solid-map-gl
pnpm create solid && pnpm i
# Install MapLibre package and placeholder Mapbox package
pnpm add solid-map-gl maplibre-gl mapbox-gl@npm:[email protected]
pnpm dev
[!NOTE]
npmenforces peer-dependency version ranges more strictly thanpnpm/yarn— the placeholder above satisfies them onpnpm/yarn, butnpm installwill fail with anERESOLVEerror since the placeholder's version doesn't matchsolid-map-gl's declaredmapbox-glrange. Usepnpm/yarnfor this install, or runnpm install --legacy-peer-depsif you must usenpm.
pnpm create solid && pnpm i
pnpm add mapbox-gl solid-map-gl
pnpm dev
[!CAUTION] If you use
viteand get the error'mapbox-gl.js' does not provide an export named 'default', add this to yourvite.config.ts:optimizeDeps: { include: ['mapbox-gl'] }
| Component | Description |
|---|---|
| MapGL | Represents map on the page |
| Source | Sources specify the geographic features to be rendered on the map |
| Layer | Layers specify the Sources |
| Layer3D | Component for BabylonJS or ThreeJS |
| Atmosphere | Specify the Atmosphere |
| Light | Specify the Light Source |
| Terrain | Specify the Terrain |
| Image | Adds an image to the map style |
| Popup | Component for |
Pass the Mapbox access token via <MapGL> options or .env file as VITE_MAPBOX_ACCESS_TOKEN
import { render } from "solid-js/web";
import { Component, createSignal } from "solid-js";
import MapGL, { Viewport, Source, Layer } from "solid-map-gl";
import 'mapbox-gl/dist/mapbox-gl.css'
const App: Component = () => {
const [viewport, setViewport] = createSignal<Viewport>({
center: [-122.45, 37.78],
zoom: 11,
});
return (
<MapGL
options={{ style: "mb:light" }}
viewport={viewport()}
onViewportChange={(evt: Viewport) => setViewport(evt)}
>
<Source
source={{
type: "geojson",
data: "https://docs.mapbox.com/mapbox-gl-js/assets/earthquakes.geojson",
}}
>
<Layer
type="circle"
paint={{
"circle-radius": 8,
"circle-color": "red",
}}
/>
</Source>
</MapGL>
);
};
render(() => <App />, document.getElementById("app")!);
Install MapLibre package and placeholder Mapbox package
pnpm add solid-map-gl maplibre-gl mapbox-gl@npm:[email protected]
yarn add solid-map-gl maplibre-gl mapbox-gl@npm:[email protected]
npm i solid-map-gl maplibre-gl mapbox-gl@npm:[email protected]
[!NOTE]
npmenforces peer-dependency version ranges more strictly thanpnpm/yarn— the placeholder above satisfies them onpnpm/yarn, butnpm installwill fail with anERESOLVEerror since the placeholder's version doesn't matchsolid-map-gl's declaredmapbox-glrange. Usepnpm/yarnfor this install, or runnpm install --legacy-peer-depsif you must usenpm.
import { render } from "solid-js/web";
import { Component, createSignal } from "solid-js";
import MapGL, { Viewport } from "solid-map-gl";
import * as maplibre from 'maplibre-gl'
import 'maplibre-gl/dist/maplibre-gl.css'
const App: Component = () => {
const [viewport, setViewport] = createSignal<Viewport>({
center: [-122.45, 37.78],
zoom: 11,
});
return (
<MapGL
mapLib={maplibre} // <- Pass MapLibre package here
options={{ style: 'https://demotiles.maplibre.org/style.json' }}
viewport={viewport()}
onViewportChange={(evt: Viewport) => setViewport(evt)}
/>
);
};
render(() => <App />, document.getElementById("app")!);
| Marker | Component for Mapbox GL JS Marker |
| Control | Represents the map's control |
| Camera | Map's camera view |
| Draw | Draw Control view |
| DeckOverlay | Adds a deck.gl overlay on top of the map |