-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Can't find the right way to manage the Plugins Methods #6
Labels
help wanted
Extra attention is needed
Comments
how to implmenets on Next.js,,, I Tray but have an error Cannot use import statement outside a module |
Hi! Can you show me your implementation? |
Merged
Elius94
added a commit
that referenced
this issue
Dec 21, 2022
Elius94/issue14 Now The library is based on the [psv](https://github.com/mistic100/Photo-Sphere-Viewer) version 5.0.0. ## Library Version Original Wrapped Library: [PhotoSphereViewer](https://github.com/mistic100/Photo-Sphere-Viewer) Version: 5.0.0 [<font color="green">**NEW**</font>] Now the component version is composed by the semantic version of the wrapper and the version of the original library. For example, the current version is 2.1.4-psv5.0.0. This means that the wrapper is in version 2.1.4 and the original library [psv](https://github.com/mistic100/Photo-Sphere-Viewer) is in version 5.0.0. #### Calling plugin methods and handling events from outside the component [**NEW**](#6) To handle events from outside the component, you need to declare the callback function in the `onReady(instance: Viewer)` prop. The `instance` is the instance of the viewer. You can call the plugin methods using the `instance.getPlugin()` method. The `instance.getPlugin()` method returns the plugin instance. You can call the plugin methods using the plugin instance. ```jsx const handleReady = (instance) => { const markersPlugs = instance.getPlugin(MarkersPlugin); if (!markersPlugs) return; markersPlugs.addMarker({ id: "imageLayer2", imageLayer: "drone.png", size: { width: 220, height: 220 }, position: { yaw: '130.5deg', pitch: '-0.1deg' }, tooltip: "Image embedded in the scene" }); markersPlugs.addEventListener("select-marker", () => { console.log("asd"); }); } return ( <div className="App"> <ReactPhotoSphereViewer src="Test_pano.jpg" plugins={plugins} height={'100vh'} width={"100%"} onReady={handleReady}></ReactPhotoSphereViewer> </div> ); ```
import "./styles.css";
import {
ReactPhotoSphereViewer,
MarkersPlugin
} from "react-photo-sphere-viewer";
import React from "react";
function App() {
const pSRef = React.createRef();
const handleReady = (instance) => {
const markersPlugs = instance.getPlugin(MarkersPlugin);
if (!markersPlugs) return;
console.log(markersPlugs);
markersPlugs.addMarker({
id: "imageLayer2",
imageLayer: "drone.png",
size: { width: 220, height: 220 },
position: { yaw: "130.5deg", pitch: "-0.1deg" },
tooltip: "Image embedded in the scene"
});
markersPlugs.addEventListener("select-marker", () => {
console.log("asd");
});
};
const plugins = [
[
MarkersPlugin,
{
// list of markers
markers: [
{
// image marker that opens the panel when clicked
id: "image",
position: { yaw: "0.33deg", pitch: "0.1deg" },
image: "pin-blue.png",
anchor: "bottom center",
size: { width: 32, height: 32 },
tooltip: "Mountain peak. <b>Click me!</b>"
},
{
// image marker rendered in the 3D scene
id: "imageLayer",
imageLayer: "drone.png",
size: { width: 220, height: 220 },
position: { yaw: "13.5deg", pitch: "-0.1deg" },
tooltip: "Image embedded in the scene"
}
]
}
]
];
const handleClick = (data) => {
console.log(data);
};
return (
<div className="App">
<ReactPhotoSphereViewer
ref={pSRef}
src="Test_Pano.jpg"
height={"100vh"}
width={"100%"}
littlePlanet={false}
onClick={handleClick}
onReady={handleReady}
plugins={plugins}
></ReactPhotoSphereViewer>
</div>
);
}
export default App; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It's currently difficult to manage the marker plugins methods.
The text was updated successfully, but these errors were encountered: