-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add example: Enter a 360° photosphere (#4428) #7942
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
clement-igonet
wants to merge
14
commits into
maplibre:main
Choose a base branch
from
clement-igonet:example/street-view-photosphere-4428
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+137
−0
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
a12ade4
feat(examples): add "Enter a 360° photosphere" example
clement-igonet 8b4bf06
Add missing doc gallery thumbnail
clement-igonet ee47b48
Fix cspell failure: whitelist proper nouns/technical terms, avoid a c…
clement-igonet a76debe
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet 42e2058
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet 4ec7b1c
Reduce cspell whitelist to the 2 unavoidable words
clement-igonet 8e237f5
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet a0ca6b1
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet 361f667
Fix photosphere never showing, use OSM basemap, reduce code
clement-igonet 759985c
Rework example to use the maplibre-gl-photosphere plugin
clement-igonet b1cb93d
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet 7512a5b
Retrigger CI (CodeQL runner version drift)
clement-igonet f0b27e1
Merge branch 'main' into example/street-view-photosphere-4428
clement-igonet 9c12057
Merge branch 'main' into example/street-view-photosphere-4428
HarelM File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,135 @@ | ||
| <!DOCTYPE html> | ||
| <html lang="en"> | ||
| <head> | ||
| <title>Enter a 360° photosphere</title> | ||
| <meta property="og:description" content="Click a marker to smoothly enter an immersive 360° photosphere at a fixed point, blended with the live map; exit to return to normal navigation." /> | ||
| <meta property="og:category" content="Camera & Animation" /> | ||
| <meta property="og:created" content="2026-07-14" /> | ||
| <meta charset='utf-8'> | ||
| <meta name="viewport" content="width=device-width, initial-scale=1"> | ||
| <link rel='stylesheet' href='../../dist/maplibre-gl.css' /> | ||
| <link rel='icon' href='data:,' /> | ||
| <style> | ||
| body { margin: 0; padding: 0; } | ||
| html, body, #map { height: 100%; } | ||
| #hint { | ||
| position: absolute; | ||
| top: 10px; | ||
| left: 10px; | ||
| z-index: 1; | ||
| background: rgba(0, 0, 0, .6); | ||
| color: #fff; | ||
| padding: 8px 12px; | ||
| font: 13px/1.4 system-ui, sans-serif; | ||
| border-radius: 4px; | ||
| pointer-events: none; | ||
| } | ||
| #exit-button { | ||
| position: absolute; | ||
| top: 10px; | ||
| right: 10px; | ||
| z-index: 1; | ||
| padding: 8px 14px; | ||
| font: 13px system-ui, sans-serif; | ||
| border: none; | ||
| border-radius: 4px; | ||
| background: rgba(0, 0, 0, .7); | ||
| color: #fff; | ||
| cursor: pointer; | ||
| display: none; | ||
| } | ||
| .photosphere-marker { | ||
| width: 22px; | ||
| height: 22px; | ||
| border-radius: 50%; | ||
| border: 2px solid #fff; | ||
| background: #2266ff; | ||
| box-shadow: 0 0 6px rgba(0, 0, 0, .6); | ||
| cursor: pointer; | ||
| } | ||
| </style> | ||
| <script type="importmap"> | ||
| { | ||
| "imports": { | ||
| "maplibre-gl": "../../dist/maplibre-gl-dev.mjs", | ||
| "maplibre-gl-photosphere": "https://unpkg.com/maplibre-gl-photosphere@0.1.0/src/index.js" | ||
|
clement-igonet marked this conversation as resolved.
|
||
| } | ||
| } | ||
| </script> | ||
| </head> | ||
| <body> | ||
| <div id="map"></div> | ||
| <div id="hint">Click the blue marker to step inside the photosphere.</div> | ||
| <button id="exit-button" type="button">Exit photosphere</button> | ||
|
|
||
| <script type="module"> | ||
| import * as maplibregl from 'maplibre-gl'; | ||
| import {Photosphere} from 'maplibre-gl-photosphere'; | ||
|
|
||
| // A bridge over the Seine, Paris - the real position this panorama was | ||
| // taken at. Photo by Alexandre Duret-Lutz, CC BY-SA 2.0, | ||
| // https://commons.wikimedia.org/w/index.php?curid=36707488 | ||
| const PHOTOSPHERE_LNGLAT = [2.286828, 48.856625]; | ||
| const OUTSIDE_VIEW = {center: PHOTOSPHERE_LNGLAT, zoom: 17, pitch: 60, bearing: -30}; | ||
|
|
||
| const map = new maplibregl.Map({ | ||
| container: 'map', | ||
| style: { | ||
| version: 8, | ||
| sources: { | ||
| osm: { | ||
| type: 'raster', | ||
| tiles: ['https://tile.openstreetmap.org/{z}/{x}/{y}.png'], | ||
| tileSize: 256, | ||
| maxzoom: 19, | ||
| attribution: '© OpenStreetMap contributors' | ||
| } | ||
| }, | ||
| layers: [{id: 'osm', type: 'raster', source: 'osm'}] | ||
| }, | ||
| center: OUTSIDE_VIEW.center, | ||
| zoom: OUTSIDE_VIEW.zoom, | ||
| pitch: OUTSIDE_VIEW.pitch, | ||
| bearing: OUTSIDE_VIEW.bearing, | ||
| minPitch: 5, | ||
| maxPitch: 175, | ||
| // Lets the plugin place the eye at its eye height instead of | ||
| // re-clamping the elevation to the ground. | ||
| centerClampedToGround: false | ||
| }); | ||
|
|
||
| const hint = document.getElementById('hint'); | ||
| const exitButton = document.getElementById('exit-button'); | ||
|
|
||
| const photosphere = new Photosphere(map, { | ||
| lngLat: PHOTOSPHERE_LNGLAT, | ||
| imageUrl: '../../docs/assets/examples/enter-a-360-photosphere-panorama.jpg', | ||
| exitView: OUTSIDE_VIEW, | ||
| onEnter: () => { | ||
| hint.textContent = 'Drag to look around.'; | ||
| exitButton.style.display = 'block'; | ||
| }, | ||
| onExit: () => { | ||
| hint.textContent = 'Click the blue marker to step inside the photosphere.'; | ||
| marker.getElement().style.display = ''; | ||
| } | ||
| }); | ||
|
|
||
| const marker = new maplibregl.Marker({ | ||
| element: Object.assign(document.createElement('div'), {className: 'photosphere-marker'}) | ||
| }) | ||
| .setLngLat(PHOTOSPHERE_LNGLAT) | ||
| .addTo(map); | ||
|
|
||
| marker.getElement().addEventListener('click', () => { | ||
| marker.getElement().style.display = 'none'; | ||
| photosphere.enter(); | ||
| }); | ||
|
|
||
| exitButton.addEventListener('click', () => { | ||
| exitButton.style.display = 'none'; | ||
| photosphere.exit(); | ||
| }); | ||
| </script> | ||
| </body> | ||
| </html> | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file should be in assets, but not inside the examples folder. this folder is kept for the examples "thumbnail" image.