Installation
This plugin requires its stylesheet. Import
@photo-sphere-viewer/markers-plugin/index.css using your preferred method, or add the CDN link to your <head>.Usage
Marker types
Every marker definition requires exactly one type property. The available types are:- image / imageLayer
- videoLayer
- html / element
- SVG shapes
- Polygons & polylines
Plugin configuration
Initial list of markers. Not updatable after init — use the
setMarkers() method instead.Default hover scale applied to all markers. Set to
true for 2× scale over 100 ms with a linear easing. Can be an object with amount, duration, and easing fields. Override per marker with hoverScale.Default animation speed for the
gotoMarker method. Updatable.When
true, a click event fires on the viewer in addition to the select-marker event. Updatable.Localization strings merged with the main viewer
lang object.Marker options
The following options apply when defining or updating a marker.Unique identifier for the marker.
Position in spherical coordinates (radians/degrees) or texture coordinates (pixels). For
imageLayer and videoLayer, you can supply an array of four corner positions instead. Ignored for polygons and polylines.Size of the marker in pixels. Required for
image and imageLayer; recommended for html and element. Ignored for polygons and polylines.Rotation applied to the marker in degrees or radians. For 2D markers only
roll applies; for 3D layer markers all axes apply (ignored when position is an array). Ignored for polygons and polylines.Scale the marker based on zoom level and/or horizontal angle. Each sub-array is
[scale at min, scale at max]. Ignored for polygons, polylines, and layers.Override the global
defaultHoverScale for this marker. Set to false to disable scaling. Accepts the same shape as defaultHoverScale. Ignored for polygons, polylines, and layers.Opacity of the marker.
Stacking order. Note:
imageLayer/videoLayer markers always render first, then polygons/polylines, then standard markers.CSS class(es) added to the marker element. Ignored for
imageLayer and videoLayer.CSS properties set on the marker element (e.g.
backgroundColor, cursor). For imageLayer and videoLayer only cursor is applicable.SVG properties set on polygon, polyline, and SVG shape markers (e.g.
fill, stroke, strokeWidth).Make a color transparent (green screen / blue screen). Only applicable to
imageLayer and videoLayer.Placement of the marker relative to its
position. Accepts any CSS position string such as 'bottom center' or '20% 80%'. Ignored for polygons and polylines.Zoom level applied when
gotoMarker() is called or when the marker is clicked in the list. If not set, the current zoom level is preserved.Initial visibility of the marker.
Tooltip shown when hovering (or clicking) the marker. Pass a string for a simple tooltip or an object to configure position, class, and trigger.Accepted positions: combinations of
top, center, bottom and left, center, right. Triggers: hover, click.HTML content displayed in the side panel when the marker is clicked.
Name shown in the markers list. Falls back to the tooltip content if not set.
Hide this marker from the markers list.
Autoplay for
videoLayer markers.Arbitrary data attached to the marker, accessible in event handlers.
Methods
addMarker(properties)
Adds a new marker to the viewer.
updateMarker(properties)
Updates a marker with new properties. The marker type cannot be changed.
removeMarker(id) / removeMarkers(ids)
Removes one or more markers by ID.
setMarkers(properties[])
Replaces all markers with a new set.
clearMarkers()
Removes all markers.
getMarker(id): Marker
Returns a marker by ID.
getCurrentMarker(): Marker
Returns the last marker clicked by the user.
gotoMarker(id, speed?): Promise
Animates the view to face a specific marker. Default speed is 8rpm; pass 0 for an immediate jump.
hideMarker(id) / showMarker(id) / toggleMarker(id)
Changes the visibility of a single marker.
showMarkerTooltip(id) / hideMarkerTooltip(id)
Forces a marker’s tooltip to be visible or hidden.
showAllTooltips() / hideAllTooltips() / toggleAllTooltips()
Controls the visibility of all tooltips at once.
Events
select-marker(marker, doubleClick, rightClick)
Fired when the user clicks a marker.
unselect-marker(marker)
Fired when a previously selected marker is deselected (user clicks elsewhere).
marker-visibility(marker, visible)
Fired when a marker’s visibility changes.
enter-marker(marker) / leave-marker(marker)
Fired when the cursor enters or leaves a marker.
Navbar buttons
This plugin adds two buttons to the default navbar:markers— toggles visibility of all markersmarkersList— opens the markers list in the side panel
If you use a custom navbar, add these button identifiers to your navbar configuration manually.
