====== Example : Export panorama snapshots ====== This example assumes you have successfully [[example_embed|embedded the component]] and [[example_checklicense|validated the license]]. Steps to take : - Listen to snapshot updates. - Process the snapshot. ===== 1. Listen to snapshot updates. ====== First we listen to viewer open and close events. Whenever a viewer is opened, we listen for the PanoramaViewerEvent.SNAPSHOT_UPDATED event. This event is dispatched when one of the viewers updated its snapshot image. Snapshot update events are dispatched when : - The user presses the camera-icon in the toolbar - The developer calls the ''updateSnapshot()'' function. client.getPanorama().addEventListener(orbit.webclient.PanoramaEvent.OPENED_VIEWER, function(e) { var viewer = client.getPanorama().getViewer(e.viewerId); viewer.addEventListener(orbit.webclient.PanoramaViewerEvent.SNAPSHOT_UPDATED,handleSnapshotUpdated); }); client.getPanorama().addEventListener(orbit.webclient.PanoramaEvent.CLOSED_VIEWER, function(e) { var viewer = client.getPanorama().getViewer(e.viewerId); viewer.removeEventListener(orbit.webclient.PanoramaViewerEvent.SNAPSHOT_UPDATED,handleSnapshotUpdated); }); ===== 2. Process the snapshot ====== There are many things a developer can do with a snapshot image. * Add the snapshot to a list of snapshots on the page. * Send the image to the server for storage. * Open the image in a popup. * ... The handler below demonstrates adding the snapshot to the html document. function handleSnapshotUpdated(e) { var viewer = client.getPanorama().getViewer(e.viewerId); $('#snapshots').append(""); } The handler below demonstrates opening a popup showing the snapshot. function handleSnapshotUpdated(e) { var viewer = client.getPanorama().getViewer(e.viewerId); var popup = window.open("","_blank"); $(popup.document.body).append(""); } ===== Complete Example =====
===== Result ===== Snapshots (to add a snapshot, click the toolbar camera button) :