← คอมโพเนนต์ทั้งหมด

แผนที่

ตัวแผนที่เอง มีสี่ธีมของ MapScale ป้ายภาษาไทยหรืออังกฤษ โหมดสว่างและมืด และเครดิตที่ลบไม่ได้

ตัวอย่างทำงานบนคลังข้อมูลประเทศไทยสาธารณะของ MapScale

ติดตั้ง

npx shadcn@latest add https://mapscale.io/r/map.json

วิธีใช้

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>
	)
}

พร็อพ

พร็อพชนิดค่าเริ่มต้นคำอธิบาย
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.

คีย์

แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ