Anmoldeep Singh

MapMarker

Component 11

About

DOM-based map markers with custom content, tooltips, popups, and draggable marker support.

Built with React and Tailwind. Copy the prompt and paste it into Claude Code, Cursor or Lovable: your agent adds MapMarker to your project and fits it to your theme.

Code

How MapMarker is used: the demo's code. The component's own source comes with a free account.

Usage.tsx

"use client";

import { useState } from "react";
import {
  Map,
  MapMarker,
  MarkerContent,
} from "@/components/ui/mapcn-map-marker";

const settings = {
  zoom: 12,
  color: "#ef4444",
  opacity: 1,
};

const START: [number, number] = [-122.4194, 37.7749];

export default function Demo(props: Partial<typeof settings>) {
  const s = { ...settings, ...props };
  const [pos, setPos] = useState<{ lng: number; lat: number }>({
    lng: START[0],
    lat: START[1],
  });

  return (
    <div className="h-screen w-screen">
      <Map viewport={{ center: START, zoom: s.zoom }}>
        <MapMarker
          longitude={pos.lng}
          latitude={pos.lat}
          draggable
          onDragEnd={(lngLat) => setPos(lngLat)}
        >
          <MarkerContent>
            <div
              className="h-4 w-4 rounded-full border-2 border-white shadow-lg"
              style={{ backgroundColor: s.color, opacity: s.opacity }}
            />
          </MarkerContent>
        </MapMarker>
      </Map>
    </div>
  );
}

Dependencies

More by Anmoldeep Singh

View all
  • MarkerPopup

    MarkerPopup

    414
  • MapArc

    MapArc

    284
  • Map

    Map

    257
  • MarkerTooltip

    MarkerTooltip

    197
  • LayerMarkers

    LayerMarkers

    134
  • MarkerLabel

    MarkerLabel

    109
  • MarkerContent

    MarkerContent

    80
  • MapControls

    MapControls

    55