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/06/22 16:31] jve@orbitgt.com |
— (current) | ||
---|---|---|---|
Line 1: | Line 1: | ||
- | ====== Restore Viewer State ====== | ||
- | |||
- | By default closing your host application means that the viewer component is destroyed and loses all state. | ||
- | |||
- | This allows you to make the viewer to remember state : | ||
- | * Remember last login | ||
- | * etc... | ||
- | |||
- | This " | ||
- | |||
- | References : | ||
- | * [[startup_option]] | ||
- | * See [[http:// | ||
- | * See [[http:// | ||
- | |||
- | ===== Listen for state changes and save them ===== | ||
- | |||
- | To listen for state changes, we listen to the '' | ||
- | |||
- | <code javascript> | ||
- | // Listen to the state-changed signal | ||
- | viewer.onAppStateChanged.add(handleAppStateChanged); | ||
- | </ | ||
- | |||
- | ===== Restore the viewer using previous state ===== | ||
- | |||
- | When creating the viewer, you have the ability to pass [[startup_option|startup options]].\\ | ||
- | The '' | ||
- | |||
- | <code javascript> | ||
- | var options = new orbitgt.mapping3d.sdk.viewer.AMap(); | ||
- | options.set(" | ||
- | </ | ||
- | |||
- | ==== Example ==== | ||
- | |||
- | Below is a full javascript 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(" | ||
- | // Create viewer | ||
- | var appElement = document.getElementById(" | ||
- | viewer = new orbitgt.mapping3d.sdk.viewer.SDKViewer(appElement, | ||
- | viewer.setSize(600, | ||
- | viewer.isReady.then(handleReady); | ||
- | } | ||
- | |||
- | // Wait for page to load | ||
- | document.addEventListener(" | ||
- | </ | ||
- | |||
- | < | ||
- | <iframe scrolling=" | ||
- | </ | ||
- | </ | ||
- | |||
Last modified:: 2018/06/22 16:31