How to use the terriajs/lib/ReactViewModels/ViewState function in terriajs

To help you get started, we’ve selected a few terriajs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github magda-io / magda / magda-preview-map / index.js View on Github external
terriaOptions.analytics = new GoogleAnalytics();
terriaOptions.viewerMode = ViewerMode.CesiumEllipsoid;

// Construct the TerriaJS application, arrange to show errors to the user, and start it up.
var terria = new Terria(terriaOptions);

// Register custom components in the core TerriaJS.  If you only want to register a subset of them, or to add your own,
// insert your custom version of the code in the registerCustomComponentTypes function here instead.
registerCustomComponentTypes(terria);

terria.welcome =
    '<h3>Terria<sup>TM</sup> is a spatial data platform that provides spatial predictive analytics</h3><div class="body-copy"><p>This interactive map uses TerriaJS<sup>TM</sup>, an open source software library developed by Data61 for building rich, web-based geospatial data explorers.  It uses Cesium<sup>TM</sup> open source 3D globe viewing software.  TerriaJS<sup>TM</sup> is used for the official Australian Government NationalMap and many other sites rich in the use of spatial data.</p><p>This map also uses Terria<sup>TM</sup> Inference Engine, a cloud-based platform for making probabilistic predictions using data in a web-based mapping environment. Terria<sup>TM</sup> Inference Engine uses state of the art machine learning algorithms developed by Data61 and designed specifically for large-scale spatial inference.</p></div>';

// Create the ViewState before terria.start so that errors have somewhere to go.
const viewState = new ViewState({
    terria: terria
});

knockout.getObservable(viewState, "notifications").subscribe(function() {
    if (!viewState.notifications || !viewState.notifications.length) return;
    const notification = viewState.notifications.shift();
    if (!notification) return;
    let msg = "";
    if (typeof notification === "string") msg = notification;
    else if (notification.message) msg = notification.message;
    else msg = String(notification);
    if (!console || !console.log) return;
    console.log(`Preview Map notifcation: \n ${msg}`);
});

if (process.env.NODE_ENV === "development") {