Examples
basics
filtering
- text filter
- bounding box filter
- nearest filter
- feature collection clipped
- feature collection filter
- convert to centroids
- buffer polygons
drawing
styling
querying
feature collection filter
This example loads a map of Africa using the "AFRICA" key.
The "AFRICA" map was created using the Mapzania MapStyler (see www.mapzania.com/manual/concepts-mapstyler).
The example uses the "usingLayer" method of the Mapzania Map object to get a "COUNTRIES" Layer Object and make chained calls to the "filterByFeatureCollection" and then the "update" method of the layer to filter and redraw the layer data.
For more on layers see: www.mapzania.com/manual/concepts-layers
For more on the Layer Object and applicable methods see:
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"
}
}
]
};
map.usingLayer("COUNTRIES")
.filterByFeatureCollection(featureCollection)
.update();
//----------------------------------------------------
// Draw the filter's feature-collection on a new layer
//----------------------------------------------------
map.usingNewLayer("FILTER")
.addFeatureCollection(featureCollection)
.style({ strokeColor: "#FFFF00", strokeWidth: 7 })
.update();
//----------------------------------------------------
});
};
#map-div {
position: absolute;
top: 0px;
left: 0px;
bottom: 0px;
right: 0px;
}
<div id="map-div"></div>