1.0.0 • Published 6 years ago

ymaps-gridmap v1.0.0

Weekly downloads
4
License
MIT
Repository
github
Last release
6 years ago

Yandex Maps API Gridmap Module

Yandex.Maps API module for data visualization.

Gridmap is a graphical representation of some spatial data, where depending on the number of entered points cell of grid (hexogon or square) are painted in different colors. Gridmap class allows to construct and display such representations over geographical maps.

Loading

  1. Put module source code (gridmap.min.js) on your CDN.

  2. Load both Yandex Maps JS API 2.1 and module source code by adding following code into <head> section of your page:

    <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
    <!-- Change my.cdn.tld to your CDN host name -->
    <script src="http://my.cdn.tld/gridmap.min.js" type="text/javascript"></script>

    If you use GeoJSON data:

    <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU&coordOrder=longlat" type="text/javascript"></script>
    <!-- Change my.cdn.tld to your CDN host name -->
    <script src="http://my.cdn.tld/gridmap.min.js" type="text/javascript"></script>

    If you use npm:

    <script src="http://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>
    npm i --save git+https://github.com/yandex-shri-fx-team/ymaps-gridmap.git
    require('ymaps-gridmap');
    
    // Or with babel
    import 'ymaps-gridmap';
  3. Get access to module functions by using ymaps.modules.require method:

    ymaps.modules.require(['Gridmap'], function (Gridmap) {
         var gridmap = new Gridmap();
    });

Gridmap

Gridmap module.

Requires: module:Polygonmap, module:util.bounds

Gridmap ⏏

Kind: Exported class

new Gridmap(data, options)

ParamTypeDescription
dataObjectPoints, GeoJSON FeatureCollections.
data.polygonsObjectGeoJSON FeatureCollections.
data.pointsObjectGeoJSON FeatureCollections.
optionsObjectOptions for customization. See more options in Polygonmap.
options.zoomnumberZoom which will be used for the grid calculation.
options.gridGridOptionsOptions which will be used in a grid calculation.
options.grid.typeGridOptionsType of grid. Can be "hexagon""square".
options.grid.paramsGridParamsOptionsOptions which will be used in a grid render
options.grid.params.bigRadiusnumberRadius of hexagon.
options.grid.params.sideLengthnumberSide length of square.
options.grid.boudsGridBoundsOptionsOptions of bound for render grid.
options.grid.boudsnumberOptions of bound for render grid.
options.grid.bouds.leftBottomArrayCoordinates of left bottom point of bound.
options.grid.bouds.topRightArrayCoordinates of right top point of bound.

gridmap.setMap(map) ⇒ Polygonmap

Set Map instance to render Polygonmap object.

Kind: instance method of Gridmap
Returns: Polygonmap - Self-reference.
Access: public

ParamTypeDescription
mapMapMap instance.

gridmap.getMap() ⇒ Map

Get the Map instance.

Kind: instance method of Gridmap
Returns: Map - Reference to Map instance.
Access: public

Gridmap~GridBounds : Object

Kind: inner typedef of Gridmap
Properties

NameTypeDescription
leftBotomArray.<number>Geographical coordinate of the left bottom point.
rigthTopArray.<number>Geographical coordinate of the right top point.

Gridmap~GridOptions : Object

Kind: inner typedef of Gridmap
Properties

NameTypeDescription
typestringType of grid.
boundsGridBoundsBounds for grid.
paramsHexagonGripParams | SquareGripParamsParams of grid.

Gridmap~HexagonGripParams : Object

Kind: inner typedef of Gridmap
Properties

NameTypeDescription
bigRadiusnumberLength of the big radius of a hexagon in pixels.

Gridmap~SquareGripParams : Object

Kind: inner typedef of Gridmap
Properties

NameTypeDescription
sideLenghtnumberLength of a side of square in pixels.

Examples

Displaying gridmap over geographical map

ymaps.modules.require(['Gridmap'], function (Gridmap) {
    const dataPoints = {
            type: 'FeatureCollection',
            features: [{
                id: 'id1',
                type: 'Feature',
                geometry: {
                    type: 'Point',
                    coordinates: [37.782551, -122.445368]
                }
            }, {
                id: 'id2',
                type: 'Feature',
                geometry: {
                    type: 'Point',
                    coordinates: [37.782745, -122.444586]
                }
            }]
        };
    const gridmap = new Gridmap(dataPoints);

    gridmap.setMap(myMap);
});

Demo

1.0.0

6 years ago

1.1.0

6 years ago