Yandex Maps API Polygonmap Module
Yandex.Maps API module for data visualization.
Polygonmap is a graphical representation of some spatial data, where depending on the number of entered points polygons are painted in different colors.
Polygonmap
class allows to construct and display such representations over geographical maps.
Loading
-
Put module source code (polygonmap.min.js) on your CDN.
-
Load both Yandex Maps JS API 2.1 and module source code by adding following code into <head> section of your page:
<!-- Change my.cdn.tld to your CDN host name -->If you use GeoJSON data:
<!-- Change my.cdn.tld to your CDN host name -->If you use npm:
npm i --save ymaps-polygonmap;// Or with babel; -
Get access to module functions by using ymaps.modules.require method:
ymapsmodules;
Polygonmap
Polygonmap module.
Requires: module:option.Manager
, module:ObjectManager
- Polygonmap
- Polygonmap ⏏
- new Polygonmap([data], [options])
- .getData() ⇒
Object
- .setData(data) ⇒
Polygonmap
- .getMap() ⇒
Map
- .setMap(map) ⇒
Polygonmap
- .destroy()
- Polygonmap ⏏
Polygonmap ⏏
new Polygonmap([data], [options])
Param | Type | Default | Description |
---|---|---|---|
[data] | Object |
Polygons and points. | |
data.polygons | Object |
GeoJSON FeatureCollections. | |
data.points | Object |
GeoJSON FeatureCollections. | |
[options] | Object |
Options for customization. | |
[options.mapper] | function |
defaultMapper |
Function of iterative transformation of features. |
[options.fillBy] | string |
"points" |
Calculate the color by points |
[options.fillByWeightProp] | string |
"weight" |
Prop name in data object, for weight value. If fillBy is "weight". |
[options.fillByWeightType] | string |
"middle" |
Type of calculate color by weight. Can be middle |
[options.colorRanges] | number | array |
4 |
Count of ranges or array of custom ranges. |
[options.colorScheme] | string | array |
"['#e66a54', '#ce4356', '#ab2960', '#571756']" |
Preset for colorize or array of custom colors. |
[options.fillOpacity] | number |
0.8 |
Opacity of polygon. |
[options.fillColorEmptyPolygon] | string |
"#f4f6f8" |
Color of polygon where points count equal 0. |
[options.strokeColor] | string |
"#fff" |
Color of polygon stroke. |
[options.strokeWidth] | number |
1 |
Width of polygon stroke. |
[options.showLegend] | boolean |
true |
Flag to show color legend. |
[options.legendTemplate] | function |
colorLegend.defaultTemplate |
Receives object {color: value} returns html legend template. |
[options.legendPosition] | object |
top: 10, right: 10 |
Position of legend, you can only change the top or bottom and right or left. |
[options.filter] | function |
Function for custom filter polygons with points. | |
[options.filterEmptyPolygons] | boolean |
false |
Flag for show polygon with count of points equal 0. |
[options.onMouseEnter] | function |
defaultOnMouseEnter |
Handler for mouseEnter event. |
[options.onMouseLeave] | function |
defaultOnMouseLeave |
Handler for mouseLeave event. |
[options.onClick] | function |
defaultOnClick |
Handler for click event. |
[options.balloonContent] | function |
defaultBalloonContent |
Function for render content of baloon. Recieves object with properties of polygon. |
[options.fillColorHover] | string |
Color of polygon on polygon hover. | |
[options.fillOpacityHover] | number |
0.9 |
Number of opacity on polygon hover. |
[options.strokeColorHover] | string |
Color of polygon stroke on polygon hover. | |
[options.strokeWidthHover] | number |
2 |
Number of stroke width on polygon hover. |
[options.fillColorActive] | string |
Color of polygon on polygon active. | |
[options.fillOpacityActive] | number |
0.9 |
Number of opacity on polygon active. |
[options.strokeColorActive] | string |
Color of polygon stroke on polygon active. | |
[options.strokeWidthActive] | number |
2 |
Number of stroke width on polygon active. |
[options.interactivity] | boolean |
true |
Flag for enable interactivity. |
Object
polygonmap.getData() ⇒ Get the data, polygons and points.
Kind: instance method of Polygonmap
Returns: Object
- Polygons and points.
Access: public
Polygonmap
polygonmap.setData(data) ⇒ Set the data, polygons and points.
Kind: instance method of Polygonmap
Returns: Polygonmap
- Self-reference.
Access: public
Param | Type | Description |
---|---|---|
data | Object |
Polygons and points. |
data.polygons | Object |
GeoJSON FeatureCollections. |
data.points | Object |
GeoJSON FeatureCollections. |
Map
polygonmap.getMap() ⇒ Get the Map instance.
Kind: instance method of Polygonmap
Returns: Map
- Reference to Map instance.
Access: public
Polygonmap
polygonmap.setMap(map) ⇒ Set Map instance to render Polygonmap object.
Kind: instance method of Polygonmap
Returns: Polygonmap
- Self-reference.
Access: public
Param | Type | Description |
---|---|---|
map | Map |
Map instance. |
polygonmap.destroy()
Destructs Polygonmap instance.
Kind: instance method of Polygonmap
Access: public
Examples
Displaying polygonmap over geographical map
ymapsmodules;
Updating polygonmap data
ymapsmodules;
Changing polygonmap representation options
ymapsmodules;