'Clicking a Photo Sphere Viewer Marker programmatically

I am trying to use the Photo Sphere Viewer and Markers together. I need to be able to click a marker programmatically. I was hoping to make a function to click them when the marker is being looked at like so:

spherePlayerInstance.on("position-updated", (e, position) => { 
  for (const [key, value] of Object.entries(markersPlugin.markers)) {
    //If the position of the marker matches the position we are looking at
    if (
      position.latitude.toFixed(1) ==
        value["props"]["position"]["latitude"].toFixed(1) &&
      position.longitude.toFixed(1) ==
        value["props"]["position"]["longitude"].toFixed(1)
    ) {
      var elem = document.getElementById(
        "psv-marker-" + value["config"]["id"]
      );
      elem.click();
    }
  }
});

This just returns undefined for the click function.

I would have thought there would be a function for clicking a marker but I don't think there is.

Any help would be appreciated. Thanks



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source