HeroUI Pro

MapNew

A MapLibre-powered map surface for custom styles, markers, popups, routes, arcs, clusters, and controls.

Usage

Anatomy

Import the Map component and compose overlays with dot notation.

import {Map} from "@heroui-pro/react";

const styles = {
  dark: "https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json",
  light: "https://basemaps.cartocdn.com/gl/voyager-gl-style/style.json",
};

<Map center={[-122.3927, 37.7816]} styles={styles} zoom={13.25}>
  <Map.Route coordinates={route} />
  <Map.Marker latitude={37.79519} longitude={-122.39385}>
    <Map.MarkerContent>
      <Map.MarkerDot color="#22c55e" />
      <Map.MarkerLabel>Start</Map.MarkerLabel>
    </Map.MarkerContent>
    <Map.MarkerTooltip>Ferry Building</Map.MarkerTooltip>
  </Map.Marker>
  <Map.Popup latitude={37.79519} longitude={-122.39385}>
    Pickup ready
  </Map.Popup>
  <Map.Controls>
    <Map.ZoomControl />
    <Map.CompassControl />
  </Map.Controls>
</Map>;

The examples above use CARTO basemaps for Voyager (light) and Dark Matter (dark). See the CARTO docs for available style URLs and usage terms.

Live Visitors

Property Listings

Live Tracking

Store Locator

Fleet Dispatch

Coverage Zones

Heatmap

Flight Paths

Incident Monitor

Style

Map uses MapLibre GL internally, but it does not ship a tile provider or basemap style. Pass mapStyle for a single MapLibre-compatible style URL/object, or styles for separate light and dark styles. These demos pass CARTO Voyager and CARTO Dark Matter through styles.

CSS Classes

Element Classes

  • .map — MapLibre container and positioning root.
  • .map__marker — Marker host element.
  • .map__marker-content — React-rendered marker content.
  • .map__default-marker — Default marker dot.
  • .map__marker-label — Marker label.
  • .map__popup-content — Popup content wrapper.
  • .map__tooltip — Marker tooltip.
  • .map__controls — Controls container.
  • .map__control-group — Grouped control surface.
  • .map__control-button — Single control button.

CSS Variables

  • --map-control-size — Control button size.
  • --map-control-offset — Controls offset from map edges.
  • --map-popup-max-width — Popup and tooltip max width.
  • --map-marker-color — Default marker fill color.
  • --map-marker-ring-color — Default marker ring color.
  • --map-route-color — Default route stroke color.
  • --map-route-width — Default route stroke width.
  • --map-route-opacity — Default route stroke opacity.

API Reference

Map

The root map container. Renders a MapLibre map with HeroUI themed controls and overlays.

PropTypeDefaultDescription
center[number, number]Initial center as [longitude, latitude].
zoomnumberInitial zoom level.
mapStylestring | StyleSpecificationSingle MapLibre-compatible style URL/object. Overrides styles.
styles{ light?: MapStyleOption; dark?: MapStyleOption }Theme-aware style URLs or objects.
theme"light" | "dark"detectedForce the map style theme.
viewportPartial<MapViewport>Controlled viewport state.
onViewportChange(viewport: MapViewport) => voidFired as the map moves.
isLoadingbooleanfalseShows the loading veil over the map.

Also supports MapLibre MapOptions except container and style.

Map.Marker

Adds a React-rendered marker at a longitude/latitude.

PropTypeDefaultDescription
latitudenumberMarker latitude.
longitudenumberMarker longitude.
draggablebooleanfalseAllows dragging the marker.
onClick(event: MouseEvent) => voidFired when the marker is clicked.
onDragEnd({ lat, lng }) => voidFired after a draggable marker moves.

Marker Parts

  • Map.MarkerContent — Renders marker content into the MapLibre marker element.
  • Map.MarkerDot — Renders the default marker dot. Customize with className, style, color, or ringColor.
  • Map.MarkerLabel — Adds a marker label with position="top" | "bottom".
  • Map.MarkerTooltip — Shows a lightweight tooltip on hover.
  • Map.MarkerPopup — Attaches a MapLibre popup to a marker.

Map.MarkerDot

Renders the default marker visual. Use it inside Map.MarkerContent when you want the built-in marker style plus labels or other custom content.

PropTypeDefaultDescription
colorstringOverrides --map-marker-color.
ringColorstringOverrides --map-marker-ring-color.

Map.Popup

Renders a standalone popup at a longitude/latitude.

PropTypeDefaultDescription
latitudenumberPopup latitude.
longitudenumberPopup longitude.
closeButtonbooleanfalseShows the HeroUI close button.
onClose() => voidFired when the popup closes.

Map.Controls

Positions map controls in a corner.

PropTypeDefaultDescription
position"top-left" | "top-right" | "bottom-left" | "bottom-right""bottom-right"Controls placement.

Use Map.ZoomControl, Map.CompassControl, Map.LocateControl, Map.FullscreenControl, Map.ControlGroup, Map.ControlButton, and Map.ControlSeparator inside Map.Controls.

Map.Route

Draws a GeoJSON line layer from coordinates.

Map.Route does not calculate navigation paths or snap points to roads. Pass the route geometry from your routing provider, such as Google Routes, Mapbox Directions, OSRM, Valhalla, or your own routing service.

PropTypeDefaultDescription
coordinates[number, number][]Route coordinates as [longitude, latitude].
colorstringCSS varRoute stroke color.
widthnumberCSS varRoute stroke width.
opacitynumberCSS varRoute stroke opacity.
dashArray[number, number]Optional dashed route pattern.

Map.Arc

Draws curved connection lines between points. Each datum needs id, from, and to.

Map.ClusterLayer

Draws clustered points from a GeoJSON point collection or GeoJSON URL.

On this page