mpetroff / pannellum

Pannellum is a lightweight, free, and open source panorama viewer for the web.
https://pannellum.org/
MIT License
4.15k stars 710 forks source link

removeHotSpot is not working #1164

Closed aliMurtaja closed 1 year ago

aliMurtaja commented 1 year ago

here's my code, removeHotSpot should have worked but it didn't

var newHotspot = {
        pitch: pitch,
        yaw: yaw,
        cssClass: "custom-hotspot",
        createTooltipFunc: hotspot,
        createTooltipArgs: "New Hotspot",
        isAddInfoEnable: true
    };

    // Add the new hotspot to the viewer
    // viewer.addHotSpot(newHotspot);

    setTimeout(() => {
    viewer.removeHotSpot(newHotspot);
    }, 3000);
    viewer.addHotSpot(newHotspot);

the hotspot added, but after 3sec it should have removed but it didn't

mpetroff commented 1 year ago

That's because you're using the removeHotSpot function incorrectly. As is stated in the API documentation, the removeHotSpot function takes a hotSpotId string as its argument, but you're passing it an object. You need to include an id attribute in your newHotspot object and set it to a string; you can then call removeHotSpot with that string as the argument to remove the hot spot.

aliMurtaja commented 1 year ago

Ohh, Thank you, now it's working.

I had been searching solution since yesterday. I am using this library in my React project, I think you should have made a different library for React. yes there is a library called react-pannellum but that is not giving the support from long-time

mpetroff commented 1 year ago

I think you should have made a different library for React.

You're entitled to your opinion, but I have no interest whatsoever in React (or Angular or Vue, or whatever other bloated client-side library is popular these days).