Anmoldeep Singh

MapMarker

Component 80

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 { useMemo } from "react";
import {
  Map,
  MapMarker,
  MarkerContent,
  MapClusterLayer,
} from "@/components/ui/mapcn-map-marker";

const settings = {
  zoom: 3,
  color: "#3b82f6",
  opacity: 1,
  pointColor: "#f97316",
  clusterRadius: 50,
};

const CENTER: [number, number] = [-98, 39];

function makePoints(): GeoJSON.FeatureCollection<GeoJSON.Point> {
  const features: GeoJSON.Feature<GeoJSON.Point>[] = [];
  for (let i = 0; i < 400; i += 1) {
    features.push({
      type: "Feature",
      properties: {},
      geometry: {
        type: "Point",
        coordinates: [-125 + Math.random() * 58, 25 + Math.random() * 24],
      },
    });
  }
  return { type: "FeatureCollection", features };
}

export default function Demo(props: Partial<typeof settings>) {
  const s = { ...settings, ...props };
  const data = useMemo(() => makePoints(), []);

  return (
    <div className="h-screen w-screen">
      <Map viewport={{ center: CENTER, zoom: s.zoom }}>
        <MapClusterLayer
          data={data}
          pointColor={s.pointColor}
          clusterRadius={s.clusterRadius}
        />
        <MapMarker longitude={CENTER[0]} latitude={CENTER[1]}>
          <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

    196
  • LayerMarkers

    LayerMarkers

    134
  • MarkerLabel

    MarkerLabel

    109
  • MarkerContent

    MarkerContent

    80
  • MapControls

    MapControls

    55