User Manual

Working with Layer Data

The Layer Object provides a number of methods for adding client-side feature data on-the-fly namely:

JavaScript


window.onload = function () {
    var map = new Mapzania.Map("map-div", "AFRICA", function () {
        var featureCollection = {
            type: "FeatureCollection",
            features: [
              {
                  type: "Feature",
                  geometry: {
                      coordinates: [
                        [
                          [0, 0], [0, 10], [10, 20], [20, 20], [20, 0], [0, 0]]
                      ],
                      type: "Polygon"
                  }
              }
            ]
        };

        // Draw the filter's feature-collection on a new layer
        map.usingNewLayer("FILTER")
            .addFeatureCollection(featureCollection)
            .update();
    });
};

The following interactive example shows this in action: