← 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.json

Usage

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

PropTypeDefaultDescription
center[number, number][100.5018, 13.7563]Initial centre as [lng, lat]. Changing it later eases the camera.
zoomnumber11Initial 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.
langstring"en"Label language: en, th, zh and more.
apiKeystringNEXT_PUBLIC_MAPSCALE_KEYPublishable key (pk_). Defaults to NEXT_PUBLIC_MAPSCALE_KEY.
mapStylestring | StyleSpecification | function-Use your own style URL, object or function instead of the hosted style.
attributionPositioncorner"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.