PSV Marker custom tooltip Demo
by mistic100
HTML
<script src="https://cdn.jsdelivr.net/npm/uevent@2/browser.js"></script>
<script src="https://cdn.jsdelivr.net/npm/three/build/three.min.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.css">
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/photo-sphere-viewer.js"></script>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/markers.css">
<script src="https://cdn.jsdelivr.net/npm/photo-sphere-viewer@4/dist/plugins/markers.js"></script>
<div id="photosphere"></div>
CSS
html, body, #photosphere {
margin: 0;
width: 100%;
height: 100%;
}
.custom-tooltip {
max-width: none;
width: 300px;
padding: 0;
box-shadow: 0 0 0 3px white;
}
.custom-tooltip img {
width: 100%;
border-radius: 4px 4px 0 0;
}
.custom-tooltip h2, .custom-tooltip p {
margin: 1rem;
text-align: justify;
}
JavaScript
const viewer = new PhotoSphereViewer.Viewer({
panorama: 'https://photo-sphere-viewer-data.netlify.app/assets/sphere.jpg',
container: 'photosphere',
loadingImg: 'https://photo-sphere-viewer.js.org/assets/photosphere-logo.gif',
caption: 'Parc national du Mercantour <b>© Damien Sorel</b>',
defaultLat: 0.4,
touchmoveTwoFingers: true,
mousewheelCtrlKey: true,
plugins: [
[PhotoSphereViewer.MarkersPlugin, {
// list of markers
markers: [{
id : 'custom-tooltip',
tooltip : {
content : `
<img src="https://photo-sphere-viewer-data.netlify.app/assets/sphere-small.jpg">
<article>
<h2>Lorem ipsum</h2>
<p>
Vivamus magna. Cras in mi at felis aliquet
congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis,
tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est.
</p>
</article>`,
className: 'custom-tooltip',
trigger : 'click',
},
latitude : 0.11,
longitude: -0.35,
image : 'https://photo-sphere-viewer.js.org/assets/pin-blue.png',
width : 32,
height : 32,
anchor : 'bottom center',
}]
}]
]
});
const markersPlugin = viewer.getPlugin(PhotoSphereViewer.MarkersPlugin);
viewer.once('ready', () => {
markersPlugin.showMarkerTooltip('custom-tooltip');
});