Socket
Socket
Sign inDemoInstall

ymaps-gridmap

Package Overview
Dependencies
11
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ymaps-gridmap

Yandex.Maps API module for data visualization.


Version published
Weekly downloads
3
Maintainers
2
Install size
2.11 MB
Created
Weekly downloads
 

Readme

Source

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
[data]ObjectPoints, GeoJSON FeatureCollections.
data.polygonsObjectGeoJSON FeatureCollections.
data.pointsObjectGeoJSON FeatureCollections.
[options]ObjectOptions for customization. See more options in Polygonmap.
[options.zoom]numberZoom which will be used for the grid calculation.
[options.grid]GridOptionsOptions which will be used in a grid calculation.
[options.grid.type]GridOptionsType of grid. Can be "hexagon"
[options.grid.params]GridParamsOptionsOptions which will be used in a grid render
[options.grid.params.bigRadius]numberRadius of hexagon.
[options.grid.params.sideLength]numberSide length of square.
[options.grid.bouds]GridBoundsOptionsOptions of bound for render grid.
[options.grid.bouds]numberOptions of bound for render grid.
[options.grid.bouds.leftBottom]ArrayCoordinates of left bottom point of bound.
[options.grid.bouds.topRight]ArrayCoordinates 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.
[bounds]GridBoundsBounds 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

Keywords

FAQs

Last updated on 27 Jun 2018

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc