mistic100 / Photo-Sphere-Viewer

A JavaScript library to display 360° sphere panoramas.
https://photo-sphere-viewer.js.org
MIT License
1.9k stars 681 forks source link

MarkersPlugin, tooltip and phone #1364

Closed Rusachok closed 2 months ago

Rusachok commented 2 months ago

Describe your problem

I'm using a MarkersPlugin and markers with tooltips. I like the markers with hints, they are perfectly displayed and pop up on the computer. And they don't work on the phone. I would like the hints to pop up when you click on i. Is it possible?

Online demo URL

https://vi-tour.ru/s/qyjtbuht/

Photo Sphere Viewer version

5.8.2

Plugins loaded

No response

Additional context

No response

mistic100 commented 2 months ago
markers.addEventListener('select-marker', ({ marker }) => {
  markers.showMarkerTooltip(marker.id);
});

written from memory, please check the API documentation for details

Rusachok commented 2 months ago

Thanks! It would be great to have toggleMarkerTooltip(id).

So, now it is work:

      virtualTour.markers.addEventListener('select-marker', ({ marker }) => {
        if (marker.state.staticTooltip){
          virtualTour.markers.hideMarkerTooltip(marker.id);
        }
        else {
          virtualTour.markers.showMarkerTooltip(marker.id);
        }
      });
mistic100 commented 2 months ago

I just realised my answer is wrong

You can change the trigger of the tooltip, check the doc.

 tooltip?: string | { content: string; position?: string; className?: string; trigger?: 'hover' | 'click' };
Rusachok commented 2 months ago

I'm ashamed, but I can't figure out how to use it in my case - with a plugin VirtualTourPlugin. And I couldn't find info in doc.

mistic100 commented 2 months ago

change tooltip: 'Дизайнерская ваза. Hand Made',

to tooltip: { content: 'Дизайнерская ваза. Hand Made', trigger: 'click' }

mistic100 commented 2 months ago

https://photo-sphere-viewer.js.org/plugins/markers.html#tooltip

Rusachok commented 2 months ago

No, it is not work with VirtualTourPlugin: https://vi-tour.ru/s/qyjtbuht/?addmap=1

mistic100 commented 2 months ago

Of course, you have extra double quote arround your object, so it interpret the whole object as a string.

I didn't put double quotes in my example above

Rusachok commented 2 months ago

Oh, shame on me! Thanks.