Skip to content

marker

Stable

A marker at a coordinate, with an optional popup and dragging that reports the new position.

Generated from the component's definition in the library, so it always matches the version this demo runs.

Attribute Type Default Description
id required string — Unique identifier for the marker
map_id required string — ID of the map to add the marker to
lng_lat required list — Marker position as [longitude, latitude]
color string "#3FB1CE" Color of the default pin (hex or named color). Defaults to "#3FB1CE". A marker with a slot ignores it
scale float 1.0 Scale of the default pin. Defaults to 1. A marker with a slot ignores it
rotation integer 0 Marker rotation in degrees, clockwise. Defaults to 0. With transition, a new rotation turns the short way over that time
draggable boolean false Whether the marker can be dragged. Defaults to false
anchor string nil Marker anchor point. One of: "center", "top", "bottom", "left", "right", etc.
offset list nil Pixel offset as [x, y]
pitch_alignment string "auto" How marker is aligned to pitch. One of: "map", "viewport", "auto"
rotation_alignment string "auto" How marker is aligned to rotation. One of: "map", "viewport", "auto"
global attributes global — Any other HTML attribute, passed on to the component's element.
popup_text string nil Text of a popup that a click on the marker opens and closes, above the pin (at the position of a marker with a slot; see Content in the module docs). Shown as plain text: HTML in it is not interpreted
popup_html string nil HTML of that popup, used when popup_text is not given. It is inserted as is, so sanitise anything that comes from users. For popup content written in HEEx, render a <.popup> at the marker's position instead
popup_focus_after_open boolean true Whether that popup moves the keyboard focus to its first focusable element (its close button, or a link or button in popup_html) as it opens, MapLibre's focusAfterOpen. Defaults to true; false leaves the focus where it is. A change rebuilds the popup, open if it was
popup_offset any nil the offset of the popup's tip from the marker's position: a number, [x, y], or a map of anchor to [x, y]
transition integer nil how long a move to a new lng_lat or rotation takes, in milliseconds; nil or 0 jumps
transition_max_distance any nil the longest move, in metres on the ground: a longer one jumps; nil for no limit
events any [] a list of event names, or :all

Slots

  • inner_block Optional.