How to use the terriajs-cesium/Source/ThirdParty/knockout.getObservable function in terriajs-cesium

To help you get started, we’ve selected a few terriajs-cesium 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 TerriaJS / terriajs / lib / Map / VariableConcept.js View on Github external
/**
     * Gets or sets a value indicating whether this concept should be de/activated using the conceptChooser.
     * Defaults to false.
     * @type {Boolean}
     */
    this.displayType = defaultValue(options.displayType, false);


    if (defined(options.id)) {
        this.id = options.id;
    }

    knockout.track(this, ['isActive', 'parent', 'hasChildren']);  // name, isSelectable, color already tracked by Concept

    knockout.getObservable(this, 'isActive').subscribe(function(nowActive) {
        // If this concept has been activated, and its parent has a color callback, use it to set this concept's color now.
        if (nowActive && defined(this.parent) && !defined(this.color) && defined(this.parent.getColorCallback)) {
            this.color = this.parent.getColorCallback();
        }
    }, this);
};
github TerriaJS / terriajs / lib / Models / TableCatalogItem.js View on Github external
*/
  this.splitDirection = ImagerySplitDirection.NONE; // NONE means show on both sides of the splitter, if there is one.

  knockout.track(this, [
    "data",
    "dataSourceUrl",
    "opacity",
    "keepOnTop",
    "showWarnings",
    "_tableStructure",
    "_dataSource",
    "_regionMapping",
    "splitDirection"
  ]);

  knockout.getObservable(this, "opacity").subscribe(function(newValue) {
    if (
      defined(this._regionMapping) &&
      defined(this._regionMapping.updateOpacity)
    ) {
      this._regionMapping.updateOpacity(newValue);
      this.terria.currentViewer.notifyRepaintRequired();
    }
  }, this);

  knockout.defineProperty(this, "concepts", {
    get: function() {
      if (defined(this._tableStructure)) {
        return [this._tableStructure];
      } else {
        return [];
      }
github TerriaJS / terriajs / lib / ReactViewModels / ViewState.js View on Github external
this._userPropertiesShowStoriesSubscription = knockout
      .getObservable(terria.userProperties, "playStory")
      .subscribe(updateIsStoryShown);

    this._mobileMenuSubscription = knockout
      .getObservable(this, "mobileMenuVisible")
      .subscribe(mobileMenuVisible => {
        if (mobileMenuVisible) {
          this.explorerPanelIsVisible = false;
          this.switchMobileView(null);
        }
      });

    this._disclaimerHandler = new DisclaimerHandler(terria, this);

    this._matchFromExplorerSubscription = knockout
      .getObservable(this, "matchFromExplorer")
      .subscribe(matchFromExplorer => {
        if (
          matchFromExplorer &&
          matchFromExplorer.params &&
          matchFromExplorer.params.catalogMemberId
        ) {
          // viewCatalogMember handles which tab to activate
          const idToFind = URI.decode(matchFromExplorer.params.catalogMemberId);
          const catalogMember = terria.catalog.shareKeyIndex[idToFind];

          if (defined(catalogMember)) {
            this.viewCatalogMember(catalogMember);
          }
        }
      });
github TerriaJS / terriajs / lib / Models / SdmxJsonCatalogItem.js View on Github external
this._fullDimensions || []
      );
    }
  });

  knockout.defineProperty(this, "activeConcepts", {
    get: function() {
      const isActive = concept => concept.isActive;
      if (defined(this._concepts) && this._concepts.length > 0) {
        return this._concepts.map(concept => concept.getNodes(isActive));
      }
      return undefined;
    }
  });

  knockout.getObservable(this, "activeConcepts").subscribe(function() {
    if (!this.isLoading) {
      // Defer the execution of this so that other knockout observables are updated when we look at them.
      // In particular, DisplayVariablesConcept's activeItems.
      runLater(() => changedActiveItems(this));
    }
  }, this);

  knockout
    .getObservable(this, "canDisplayPercent")
    .subscribe(function(canDisplayPercent) {
      // If canDisplayPercent becomes false, must also turn off displayPercent.
      if (!canDisplayPercent) {
        this.displayPercent = false;
      }
    }, this);
github magda-io / magda / magda-preview-map / lib / Models / MagdaCatalogItem.js View on Github external
newItem.dataCustodian = options.dataCustodian;
        }

        if (typeof options.itemProperties === "object") {
            newItem.updateFromJson(options.itemProperties);
        }

        if (defined(parent)) {
            newItem.id = parent.uniqueId + "/" + distribution.id;
        }

        if (defined(options.zoomOnEnable)) {
            newItem.zoomOnEnable = options.zoomOnEnable;
        }

        knockout.getObservable(newItem, "isLoading").subscribe(function(value) {
            try {
                if (value === true) return;
                if (window.parent !== window) {
                    window.parent.postMessage("loading complete", "*");
                }

                if (window.opener) {
                    window.opener.postMessage("loading complete", "*");
                }
            } catch (e) {
                console.log(e);
            }
        });

        return newItem;
    });
github TerriaJS / terriajs / lib / ViewModels / PointParameterEditor.js View on Github external
get: function() {
            if (!defined(knockout.getObservable(this.parameterValues, this.parameter.id))) {
                knockout.track(this.parameterValues, [this.parameter.id]);
            }

            var cartographic = this.parameterValues[this.parameter.id];
            if (defined(cartographic)) {
                return CesiumMath.toDegrees(cartographic.longitude) + ',' + CesiumMath.toDegrees(cartographic.latitude);
            } else {
                return '';
            }
        },
        set: function(value) {
github TerriaJS / terriajs / lib / ViewModels / RegionParameterEditor.js View on Github external
if (index >= 0 && this._regionNames[index]) {
                return this._regionNames[index];
            } else {
                return region.id;
            }
        },
        set: function(value) {
            this.autocompleteVisible = true;
            this.value = undefined;
            this._displayValue = value;
        }
    });

    var that = this;

    knockout.getObservable(this.terriaForRegionSelection, 'pickedFeatures').subscribe(function() {
        var pickedFeatures = that.terriaForRegionSelection.pickedFeatures;
        that._lastPickedFeatures = pickedFeatures;
        when(pickedFeatures.allFeaturesAvailablePromise, function() {
            if (pickedFeatures !== that._lastPickedFeatures || pickedFeatures.features.length === 0) {
                return;
            }

            var feature = pickedFeatures.features[0];
            that._lastRegionFeature = feature.data;
            that.value = that.parameter.findRegionByID(feature.properties[that.regionProvider.regionProp], that._parameterValues);

            if (defined(that._selectedRegionCatalogItem)) {
                that._selectedRegionCatalogItem.isEnabled = false;
                that._selectedRegionCatalogItem = undefined;
            }
github TerriaJS / terriajs / lib / ReactViewModels / SearchState.js View on Github external
knockout.track(this, [
      "catalogSearchProvider",
      "locationSearchProviders",
      "catalogSearchText",
      "isWaitingToStartCatalogSearch",
      "locationSearchText",
      "isWaitingToStartLocationSearch",
      "unifiedSearchText",
      "isWaitingToStartUnifiedSearch",
      "showLocationSearchResults",
      "showMobileLocationSearch",
      "showMobileCatalogSearch",
      "sourcePinDataSource"
    ]);

    knockout.getObservable(this, "catalogSearchText").subscribe(() => {
      this.isWaitingToStartCatalogSearch = true;
      this.catalogSearchProvider.search("");
    });

    knockout.getObservable(this, "locationSearchText").subscribe(() => {
      this.isWaitingToStartLocationSearch = true;
      this.locationSearchProviders.forEach(provider => {
        provider.search("");
      });
    });

    knockout.getObservable(this, "unifiedSearchText").subscribe(() => {
      this.isWaitingToStartUnifiedSearch = true;
      this.unifiedSearchProviders.forEach(provider => {
        provider.search("");
      });
github TerriaJS / terriajs / lib / Models / Terria.js View on Github external
* @type {CameraView}
     */
    knockout.defineProperty(this, 'initialView', {
        get: function() {
            if (this._initialView) {
                return this._initialView;
            } else {
                return this.homeView;
            }
        },
        set: function(value) {
            this._initialView = value;
        }
    });

    knockout.getObservable(this, 'initialView').subscribe(function() {
        if (this.zoomWhenInitialViewChanges && defined(this.currentViewer)) {
            this.currentViewer.zoomTo(this.initialView, 2.0);
        }
    }, this);
};
github TerriaJS / terriajs / lib / Models / CsvCatalogItem.js View on Github external
that.legendUrl = source.getLegendGraphic();
                that.terria.currentViewer.notifyRepaintRequired();
            };
            return [displayVariablesConcept];
        }
    });

    knockout.getObservable(this, 'opacity').subscribe(function(newValue) {
        updateOpacity(this);
    }, this);

    knockout.getObservable(this, 'isShown').subscribe(function() {
        updateClockSubscription(this);
    }, this);

    knockout.getObservable(this, 'clock').subscribe(function() {
        updateClockSubscription(this);
    }, this);

    /**
     * Gets or sets the tableStyle object
     * TODO: add definition for subfields
     * @type {Object}
     */
    knockout.defineProperty(this, 'tableStyle', {
        get : function() {
            return this._tableStyle;
        },
        set : function(value) {
            updateTableStyle(this, value);
        }
    });

terriajs-cesium

Cesium for TerriaJS.

Apache-2.0
Latest version published 8 months ago

Package Health Score

68 / 100
Full package analysis