Options
All
  • Public
  • Public/Protected
  • All
Menu

A QueryProvider allows you to define what Feature instances must be shown at different map scales. A QueryProvider must be configured on a data loading strategy. A LoadingStrategy is configured on a FeatureLayer and allows you to control when and what data is downloaded from the server to be visualized in that layer.

When the map scale changes, for example because a user zooms in or out, a FeatureLayer's LoadingStrategy will consult its QueryProvider if the data that must be shown at the new scale level is different from the data shown at the previous scale level. The QueryProvider can then return a value (called a query object) that expresses the filter conditions that the data at that level must satisfy. The value returned by the QueryProvider will be passed to the FeatureModel's query() method in the query parameter. The FeatureModel's Store can then interpret that value to send a request to the server to download the desired data.

A QueryProvider works as follows:

  • getQueryLevelScales must return an array of map scale thresholds. If no thresholds are defined, the same query object will be used at every map scale.
  • Subsequently, an index in this array is passed to getQueryForLevel to retrieve the corresponding query object.

This mechanism is similar to level-of-detail in FeaturePainter.

since

2015.0

Hierarchy

  • QueryProvider

Overview

Properties

Static QUERY_NONE

QUERY_NONE: object

Indicates that no data should be queried from the backing store.

Methods

getQueryForLevel

  • (level: number): object | null
  • Returns the query to use on the backing Store for the given level scale. This query can be any value, provided it can be understood by the store. For a WFS store, this can be an OGC filter, for a REST store, this can be an object that contains a number of key-value pairs that will be transmitted to the server as URL parameters. If no data should be downloaded from the server, return QUERY_NONE.

    The example returns a query object that instructs the store to download stores with a specific minimum population. As you zoom in on the map, also smaller cities will be loaded.

    Parameters

    • level: number

      the current level of detail as a non-negative integer value. The least precise detail level is 0. The number of available detail levels is determined by the array returned by getQueryLevelScales.

    Returns object | null

    The query to use on the backing Store.

    CitiesQueryProvider.prototype.getQueryForLevel = function(level) {
      var queries = [
        QueryProvider.QUERY_NONE,
        {minimum_population: 1000000},
        {minimum_population: 500000},
        {minimum_population: 0}
      ];
      return queries[level];
    };

getQueryLevelScales

  • Returns an array of map scales that determine when the layer should switch from one query to another. These s cales must be ordered from the smallest scale (zoomed out) to the largest scale (zoomed in). The scale must be expressed in the same unit as th map scale.

    This method needs only to be implemented if there is at least a single scale break.

    Parameters

    • Optional layer: FeatureLayer

      the layer for which the detail level scales are being requested

    • Optional map: Map

      the map for which the detail level scales are being requested

    Returns number[]

    the switch scales for each level of detail.

    MyProvider.prototype.getQueryLevelScales = function(layer, map) {
      return [1/200000, 1/10000, 1/100];
    };

invalidate

  • (): void
  • Invalidates the query provider. Call this method to indicate that the query must be refreshed. You would use this to ensure a FeatureLayer queries the model again.

    myFeatureLayer.loadingStrategy.queryProvider.invalidate();

    Returns void

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Type alias with type parameter
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method