JS API
Map Object
QueryEngine Object
Layer Object
Feature Object
Query Object
GeoJson Function Library (Experimental)

QueryEngine Object

The QueryEngine object provides an entry point for interacting with spatial data.

Unlike the Map Object, it does not perform any graphic functions.

Rather it allows the user to fetch data, manipulate and filter that data and then decide where that data can be used.


The object is instantiated in the following way:

new Mapzania.QueryEngine()

Parameters

No parameters

Example

 var qry = new Mapzania.QueryEngine();

Methods

usingFeatureCollection

Gets a Query Object based on a A GeoJSON FeatureCollection provided by the user.

This object is a fluent object and can be used to chain method calls to the query as per the example below.

Parameters

Name Required Description
featureCollection Yes A GeoJSON FeatureCollection to be used in the query

Example

var gjson = {
    type: "FeatureCollection",
    features: [...]
};

 var qry = new Mapzania.QueryEngine();

qry.usingFeatureCollection(gjson)
    .filterByText("Landlocked=='Y'")
    .bufferGeometry(500)
    .apply()
    .then(function (data) {
        console.log(data);
    })

usingLayerSource

Gets a Query Object based on the key of the layer-source.

This object is a fluent object and can be used to chain method calls to the query as per the example below.

Parameters

Name Required Description
sourceKey Yes The key of the layer-source to be used in the query

Example


 var qry = new Mapzania.QueryEngine();

    qry.usingLayerSource("COUNTRIES")
        .filterByText("Landlocked=='Y'")
        .bufferGeometry(500)
        .apply()
        .then(function (data) {
            console.log(data);
        })

usingMapLayer

Gets a Query Object based on a layer of an existing Map Object.

It is used specifically to run queries based on the layers of an existing Map Object without interfering with the map itself.

This object is a fluent object and can be used to chain method calls to the query as per the example below.

Parameters

Name Required Description
map Yes An existing Map Object
layerKey Yes The key of the layer to be used in the query.
options No An object for custom configuration of the map-layer query. The possible options are shown in the section below.

Options

Name Default Description
useFilters true If set to true, the query will take into consideration any filters that have been applied to the map layer.
useState true If set to true, the query will take into consideration the state of the map layer. This includes any client-side features that have been added to the layer as well as whether the layer is visible or not.

Example

var map = new Mapzania.Map("map-div", "LONDON", function () {

    var qry = new Mapzania.QueryEngine();

    qry.usingMapLayer(map, "WARD", { 
            useState: false, 
            useFilters: true 
        })
        .convertToCentroids()
        .apply()
        .then(function (data) {
            console.log(data);
        });
});