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

Events

[layer_key]_layer_changed

Fired when the data in a layer changes. This can be due to map interaction such as zoom, pan or refresh.

[layer_key] is always the lowercase value of the layer key. For examples if the 'STREETS' layer changes, the event that is raised is 'streets_layer_changed'.


Event Result

A GeoJSON FeatureCollection.


Example

var map = new Mapzania.Map("map-div", "WORLD", function(){
    map.on("streets_layer_changed", function (data) {
        console.log(data);
    });

    map.usingLayer("STREETS)
        .filterByText("StreetType=='HIGHWAY'")
        .update();
});

mouse_mode_set

Fired when the user changes the MouseMode of the Map object.


Event Result

An integer value based on the MouseMode that was set.

MouseMode Value
Pan 1
DrawPoint 3
DrawLine 4
DrawPolygon 5

Example

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

    map.on("mouse_mode_set", function (data) {
        console.log(data);
    });

    map.setMouseMode(Mapzania.MouseModes.Pan);
});

drawing_done

Fired when the user completes a drawing action on the map.


Event Result

GeoJSON Geometry based on the current MouseMode as per the table below:

MouseMode Result Type
DrawPoint GeoJSON Point
DrawLine GeoJSON LineString
DrawPolygon GeoJSON Polygon

Example

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

    map.on("drawing_done", function (data) {
        console.log(data);
    });

    map.setMouseMode(Mapzania.MouseModes.DrawLine);
});

view_changed

Fired when the view is changed by the user due to panning or zooming.


Event Result

An json object with the following properties:

MouseMode Result Type
boundingBox GeoJSON bounding box
zoom integer
center GeoJSON Point

Example

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

    map.on("view_changed", function (data) {
        console.log(data);
    });

    map.fitToBoundingBox([10,10,20,20]);
});