← All components
Map
The map itself. Four MapScale themes, Thai or English labels, light and dark, and a credit that cannot be removed.
Previews run on MapScale's public Thailand archive.
Install
npx shadcn@latest add https://mapscale.io/r/map.jsonUsage
import { Map } from "@/components/mapscale/map"
import { MapControls } from "@/components/mapscale/map-controls"
export default function Page() {
return (
<div className="h-[480px]">
<Map style="atlas" lang="th" center={[100.535, 13.745]} zoom={12}>
<MapControls styleSwitcher />
</Map>
</div>
)
}Props
| Prop | Type | Default | Description |
|---|---|---|---|
| center | [number, number] | [100.5018, 13.7563] | Initial centre as [lng, lat]. Changing it later eases the camera. |
| zoom | number | 11 | Initial zoom level. |
| style | "streets" | "dark" | "atlas" | "watercolor" | "streets" | Basemap theme: streets, dark, atlas or watercolor. |
| theme | "fixed" | "system" | "fixed" | With "system", the map switches to the dark theme when <html> has the dark class. |
| lang | string | "en" | Label language: en, th, zh and more. |
| apiKey | string | NEXT_PUBLIC_MAPSCALE_KEY | Publishable key (pk_). Defaults to NEXT_PUBLIC_MAPSCALE_KEY. |
| mapStyle | string | StyleSpecification | function | - | Use your own style URL, object or function instead of the hosted style. |
| attributionPosition | corner | "bottom-right" | Moves the required attribution. There is no prop that removes it. |
| onLoad | (map) => void | - | Called with the maplibre map once the first style has loaded. |
Keys
Maps, autocomplete and place details use a publishable pk_ key that is safe in the browser. Routing and isochrones need a secret sk_ key, so they go through the proxy route your app serves.