images in hotspots automatically link to themselves
Opened this issue · 2 comments
Hi, everything's running awesomely so far and this viewer is incredible. I have set up some standard hotspots with images included like this:
{
"pitch": -15.21401074363825,
"yaw": -49.12633812097041,
"type": "info",
"cssClass": "image",
"text": "xyz",
"image": './assets/image.jpg',
},
I don't even think this is officially supported but after messing with the custom hotspot class it works just fine. The only problem is, that tapping/ clickingthe image takes you to a new tab of that image since it references itself as a link by default. I haven't found a simple way to prevent this behaviour ansd was wondering if someone new the way to do this?
Thanks in advance for any time spent,
Michael
I don't even think this is officially supported
It isn't.
I haven't found a simple way to prevent this behaviour
If you use the current Git master
branch, adding "URL": "#"
to the hot spot configuration should work.
Otherwise, you can use a custom createTooltipFunc
with the hot spot to create the tooltip with the image. Something like this:
function createImageTooltip(div, imageURL) {
var span = document.createElement('span');
span.style.maxWidth = 'initial';
var image = document.createElement('img');
image.src = imageURL;
image.style.width = '200px';
image.style.paddingTop = '5px';
span.appendChild(image);
div.classList.add('pnlm-tooltip');
div.appendChild(span);
span.style.width = span.scrollWidth - 20 + 'px';
span.style.marginLeft = -(span.scrollWidth - div.offsetWidth) / 2 + 'px';
span.style.marginTop = -span.scrollHeight - 12 + 'px';
}
where you'd have a hot spot configuration something like this:
{
"pitch": -0.9,
"yaw": 144.4,
"type": "info",
"createTooltipFunc": createImageTooltip,
"createTooltipArgs": "/path/to/image.jpg"
}
"URL": "#" has already done the trick, I'll be lloking into your custom tooltip suggestion suggestion anyway because the more time I spent fiddling with pannellum, the more ideas I have. I'm using Pannellum in my capacity as an inner city elemantary school teacher and bringing scnes to the classroom the children otherwise wouldn't be able to see is amazing.
Thanks again and tea sent your way!