JS API
- Parameters
- Options
- Example
- Methods
- fitToBoundingBox
- getBoundingBox
- getInitialBoundingBox
- getLayers
- getMouseMode
- off
- on
- once
- refresh
- reset
- setMouseMode
- usingLayer
- usingNewLayer
- Events
- Parameters
- Example
- Methods
- addFeature
- addFeatureCollection
- bringForwards
- bufferGeometry
- changeProperties
- clearFilters
- clearFeatures
- clearStyle
- clipByFeatureCollection
- convertToCentroids
- filterByBoundingBox
- filterByFeatureCollection
- filterByNearest
- filterByText
- getFeatureCollection
- hide
- sendBackwards
- show
- style
- update
- usingFeature
Feature Object
The Feature object is created using the usingFeature method of the Layer Object.
Parameters
No parameters.
NOTE: The Feature object is never created directly, rather it is created using the usingFeature method of the Layer Object.
Example
var map = new Mapzania.Map("map-div", "AFRICA", function () {
map.usingLayer("COUNTRIES")
.filterByText("LandLocked=='Y'")
.style({ fillColor: "#CCCCCC"})
.usingFeature("107")
.style({ fillColor: "#FF0000"})
.update();
});
Methods
clearStyle
Clears all client-side styles that were applied to a feature.
Parameters
No parameters.
Example
var map = new Mapzania.Map("map-div", "WORLD");
map.usingLayer("COUNTRIES")
.usingFeature("107")
.clearStyle()
.update()
hide
Ensures that the feature is hidden.
Parameters
No parameters.
Example
var map = new Mapzania.Map("map-div", "AFRICA", function () {
map.usingLayer("COUNTRIES")
.usingFeature("107")
.hide();
show
Ensures that the feature is visible.
Parameters
No parameters.
Example
var map = new Mapzania.Map("map-div", "AFRICA", function () {
map.usingLayer("COUNTRIES")
.usingFeature("107")
.show();
style
Sets the style of the single feature.
Parameters
Name | Required | Description |
---|---|---|
style | Yes | An object defining the style. All properties are optional and may be left out. - fillColor (The fill color of the feature) - strokeColor (The stroke color of the feature) - strokeWidth (The width of the stroke of the feature) - size (Applies to point layers and is the diameter of the point) |
Example
var map = new Mapzania.Map("map-div", "AFRICA", function () {
map.usingLayer("COUNTRIES")
.usingFeature("107")
.style({ fillColor: "#FF0000"})
.update();
update
Updates the feature's layer. This is typical done to make style changes as per the example below.
Parameters
No parameters.
Example
var map = new Mapzania.Map("map-div", "AFRICA", function () {
map.usingLayer("COUNTRIES")
.usingFeature("107")
.style({ fillColor: "#FF0000"})
.update();