Geovisualization Developer's Guide

H.datalens. ObjectLayer

Class Summary

Extends: H.map.layer.ObjectLayer

Presents data as points or spatial map objects with data-driven styles and client-side clustering.

[ For full details, see the Class Details ]

Class Description

Applicable for drawing interactive map objects like markers, polygons, circles and other instances of H.map.Object. Source of data can be either tiled or not tiled. Styles for objects can be parametrized with data rows and zoom level. Allows to create data-driven icons for markers like donuts or bars. Also enables clustering and data domains for visualizing up to 100k points or more.
var layer = new H.datalens.ObjectLayer(
  queryTileProvider,
  {
    rowToMapObject: function(row) {
      return new H.map.Marker(row.lat, row.lon);
    }
  }
);

Constructor Details

H.datalens.ObjectLayer (provider, options)

Parameters:
 
provider : { H.map.provider.RemoteTileProvider | H.datalens.Provider | H.datalens.QueryProvider | H.datalens.QueryTileProvider }
Data source (tiled or not)
options : { H.datalens.ObjectLayer.Options }
Defines data processing, clustering and data-driven styling

Property Details

static defaultDataToRows : { function( H.datalens.Service.Data ) : Array.< H.datalens.ObjectLayer.Row > }

Default value for dataToRows callback option. It represents each row as an object where property names correspond to data column names.
var layer = new H.datalens.ObjectLayer(
   provider,
   {
     dataToRows: function(data) {
       return H.datalens.ObjectLayer.defaultDataToRows(
         data
       ).filter(function() {
         ...
       })
     },
     ...
   }
);

Method Details

static createIcon (svg, options) : { H.map.Icon }

A factory method for data-driven icons. The method allows you to build an icon from SVG markup or JsonML object. Provides caching of icons with the same markup.
var metricScale = d3.linearScale();
...
var layer = new H.datalens.ObjectLayer(
 provider,
 {
   rowToStyle: function (row) {
     return {},
     icon: H.datalens.ObjectLayer.createIcon(
       [
         'svg',
         {viewBox: [-8, -8, 8, 8]},
         ['circle', {r: metricScale(row.metric), cx: 0, cy: 0}],
       ],
       {size: 16}
     )
   }
});
Parameters:
 
svg : { string | array }
SVG presented as markup or JsonML Array
options : { H.map.Icon.Options } [optional]
Icon options (eg size and anchor). Note that the default anchor is in the middle.
options.size : { H.math.ISize | number } [optional]
When the icon is a square, you can define the size as a number in pixels
Returns:
 
: { H.map.Icon }
Icon which can be used for marker or cluster

static getIconCache () : { H.util.Cache }

Returns cache of icons created with the createIcon method. Can be used to clean the icon cache.

Returns:
 
: { H.util.Cache }
Icon cache

redraw ()

Force re-rendering of the layer. In the case where the callbacks passed to the layer options are not pure functions, you can call this method to force re-rendering.

updateObjectStyle (object, state)

Recalculates the style and applies it to the map object based on the new StyleState

Parameters:
 
object : { H.map.Object }
Map object
state : { H.datalens.ObjectLayer.StyleState }
New state

static createReusableMarker (id, args) : { H.map.Marker }

A factory method for creating reusable markers.

Parameters:
 
id : { number | string }
a unique id for the marker
args : { object }
arguments passed to the constructor
Returns:
 
: { H.map.Marker }
- a reusable marker