Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
dev:developer:3dmapping_sdk:viewer_state [2018/08/07 12:40] pieter.bonne@orbitgt.com |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Track Viewer State ====== | ||
- | |||
- | Closing your host application usually means that the viewer component is destroyed and loses all state. | ||
- | |||
- | This " | ||
- | |||
- | ===== Saving state ===== | ||
- | |||
- | To listen for state changes, we listen to the '' | ||
- | |||
- | <code javascript> | ||
- | // Listen to the state-changed signal | ||
- | viewer.onAppStateChanged.add(handleAppStateChanged); | ||
- | </ | ||
- | |||
- | ===== Loading state on startup ===== | ||
- | |||
- | When creating the viewer, you have the ability to pass startup options.\\ | ||
- | The ' | ||
- | |||
- | Startup options can be provided only once. They can be passed to the constructor function of the Viewer class. | ||
- | |||
- | ===== Example ===== | ||
- | |||
- | Below is a Javascript-specific example using '' | ||
- | Try logging in to the viewer with " | ||
- | |||
- | <code javascript> | ||
- | var viewer; | ||
- | |||
- | /** | ||
- | * Called when something changes to the viewer state. | ||
- | */ | ||
- | function handleAppStateChanged(state) { | ||
- | // Save state somewhere... | ||
- | window.localStorage.setItem(" | ||
- | } | ||
- | |||
- | /** | ||
- | * Called when the viewer component is ready for interaction. | ||
- | */ | ||
- | function handleReady() { | ||
- | // Listen to the state-changed signal | ||
- | viewer.onAppStateChanged.add(handleAppStateChanged); | ||
- | } | ||
- | |||
- | /** | ||
- | * Called when the page is full loaded. | ||
- | */ | ||
- | function handleDOMReady() { | ||
- | // Create viewer startup options | ||
- | var options = new orbitgt.mapping3d.sdk.viewer.AMap(); | ||
- | options.set(orbitgt.mapping3d.sdk.viewer.Constants.STARTUP_APP_STATE, | ||
- | // Create viewer | ||
- | var appElement = document.getElementById(" | ||
- | viewer = new orbitgt.mapping3d.sdk.viewer.SDKViewer(" | ||
- | viewer.setSize(600, | ||
- | viewer.isReady.then(handleReady); | ||
- | } | ||
- | |||
- | // Wait for page to load | ||
- | document.addEventListener(" | ||
- | </ | ||
- | |||
- | < | ||
- | <iframe scrolling=" | ||
- | </ | ||
- | </ | ||
- | |||
Last modified:: 2018/08/07 12:40