Installation
This plugin requires its stylesheet. Import
@photo-sphere-viewer/map-plugin/index.css or add the CDN link to your <head>.Usage
The minimum configuration requiresimageUrl (path to the map image) and center (the pixel coordinates of the panorama on that image).
The north of the compass is always toward the top of the map image, before applying any
rotation.Configuration
URL of the map image. Not updatable after init — use
setImage() instead.Pixel position of the panorama on the map image. Updatable.
Rotation applied to the map to align it with the panorama. Accepts radians or a degree string such as
'45deg'. Updatable.Shape of the map widget. Updatable.
Size of the widget. Accepts any CSS length unit (
px, rem, vh, etc.). Updatable.Position of the widget on screen. Accepted values: combinations of
top/bottom and left/right. Updatable.When
true, the map does not rotate — only the center pin rotates to show the current viewing direction. Updatable.SVG or image URL drawn on top of the map. Set to
null to disable. Defaults to a built-in SVG. Updatable.SVG or image URL used for the central position pin. Defaults to a built-in SVG. Updatable.
Size of the central pin in pixels. Updatable.
Color of the viewing-direction cone. Set to
null to disable. Updatable.Size of the viewing-direction cone. Updatable.
Small dot markers on the map. Updatable. See Hotspots below. You can also call
setHotspots().Default style applied to all hotspots. Updatable. Individual hotspots can override this with their own
style.| Field | Type | Default | Description |
|---|---|---|---|
size | number | 15 | Hotspot diameter |
image | string | — | SVG or image URL |
color | string | 'white' | Fill color when no image |
borderSize | number | 0 | Border width |
borderColor | string | null | Border color |
hoverSize | number | null | Size on hover |
hoverImage | string | null | Image on hover |
hoverColor | string | null | Color on hover |
hoverBorderSize | number | 4 | Border width on hover |
hoverBorderColor | string | 'rgba(255,255,255,0.6)' | Border color on hover |
zIndex | number | null | Stacking order |
Initial zoom level of the map.
Maximum zoom level. Updatable.
Minimum zoom level. Updatable.
Show the map when the first panorama loads.
Minimize the map when the user clicks a hotspot or marker. Updatable.
Control which buttons are visible around the map widget.
Localization strings merged with the main viewer
lang object.Hotspots
Identifier used to match
select-hotspot events. Auto-generated if not provided.Position as an angle (radians) and a distance (pixels on the map image) from the panorama center.
Absolute pixel position on the map image. Use either
yaw+distance or x+y.Overrides the default
spotStyle for this hotspot.Tooltip shown when hovering the hotspot.
Methods
setHotspots(hotspots)
Replaces all hotspots.
clearHotspots()
Removes all hotspots.
setImage(url, center?, rotation?)
Replaces the map image.
setCenter(center, resetView?)
Updates the panorama position on the map. When resetView is false (default true), the map viewport does not reposition, only the center pin moves.
close() / open()
Toggles between closed and open states.
maximize() / minimize()
Toggles between maximized and minimized views. Has no effect when the map is closed.
setZoom(level)
Sets the zoom level (clamped between minZoom and maxZoom).
Events
select-hotspot(hotspotId)
Fired when the user clicks a hotspot.
view-changed(view)
Fired when the map state changes. view is 'maximized', 'normal', or 'closed'.
SCSS variables
| Variable | Default | Description |
|---|---|---|
$radius | 8px | Corner radius (square shape only) |
$shadow | 0 0 5px rgba(0,0,0,.7) | Widget shadow |
$background | rgba(61,61,61,.7) | Map background color |
$button-size | 34px | Button size |
$button-background | rgba(0,0,0,.5) | Button background |
$button-color | core.$buttons-color | Button icon color |
$toolbar-font | 12px sans-serif | Zoom indicator font |
$toolbar-text-color | white | Zoom indicator text color |
$toolbar-background | #222 | Zoom indicator background |
$transition | ease-in-out .3s | Animation transition |
