← คอมโพเนนต์ทั้งหมด
แผนที่
ตัวแผนที่เอง มีสี่ธีมของ 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. |
| 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. |
คีย์
แผนที่ การค้นหาที่อยู่ และรายละเอียดสถานที่ใช้คีย์ pk_ ที่ปลอดภัยบนเบราว์เซอร์ ส่วนเส้นทางและ isochrone ต้องใช้คีย์ลับ sk_ จึงต้องผ่านเส้นทางพร็อกซีบนเซิร์ฟเวอร์ของแอปคุณ