Installation

How to install and set up ai-map in your project.

Prerequisites

A project with Tailwind CSS and shadcn/ui set up.

Installation

Run the following command to add the map component:

npx shadcn@latest add site-url-here/maps/map.json

This will install @amap/amap-jsapi-loader and add the map component to your project.

Usage

Import and use the map component:

import { Map, MapControls } from "@/components/ui/map";
import { Card } from "@/components/ui/card";

export function MyMap() {
  return (
    <Card className="h-[300px] p-0 overflow-hidden">
      <Map center={[116.397428, 39.90923]} zoom={11}>
        <MapControls />
      </Map>
    </Card>
  );
}
Note: AMap requires a valid API key (NEXT_PUBLIC_AMAP_KEY). Get your key at lbs.amap.com. Map styles automatically switch between light and dark themes.