Quickstart
To get started with solidjs-maplibre-gl
in just a few minutes, follow the steps below
-
Initialize a new solidjs project:
Terminal window bun create solid# orpnpm create solid# oryarn create solid -
Install the package from npm:
Terminal window bun add -D solidjs-maplibre-gl -
Add an example map to the root
App.tsx
or your routeindex.tsx
App.tsx import type { Component } from 'solid-js';import { Maplibre } from 'solidjs-maplibre-gl';import 'maplibre-gl/dist/maplibre-gl.css';const App: Component = () => {return (<Maplibrestyle={{height: "400px",width: "100%",}}options={{style:"https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",}}/>)} -
The
Maplibre
component accepts children props such asmarkers
,tooltips
… etc. Lets add aMarker
child to theMaplibre
component.App.tsx import type { Component } from 'solid-js';import { Maplibre, Marker } from 'solidjs-maplibre-gl'import 'maplibre-gl/dist/maplibre-gl.css';const App: Component = () => {return (<Maplibrestyle={{height: "400px",width: "100%",}}options={{style:"https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",center: [142, 43],zoom:5}}/>><Marker lnglat={[141.692222, 42.775]} /></Maplibre>)}
And thats it! You’ve set up your first map with solidjs-maplibre-gl
Further reading
Section titled “Further reading”- See the reference guide to understand how to work with the library