diff --git a/lib/index.js b/lib/index.js index d4a8aed..79d49d2 100644 --- a/lib/index.js +++ b/lib/index.js @@ -174,9 +174,18 @@ export default class Layer extends EE.EventEmitter { } } }; - if (rules) { + + // temporary till cluster feature is unified (eta july 2016) + if (rules && rules.cluster) { + out.layer.style.cluster = rules.cluster; + out.layer.style.url = rules.url; + out.layer.style.height = rules.height; + out.layer.style.width = rules.width; + out.layer.style.colorTransform = rules.colorTransform; + } else if (rules) { out.layer.style.rules = rules; } + out.layer.query.where = query; switch (type) { case 'line': @@ -185,6 +194,8 @@ export default class Layer extends EE.EventEmitter { case 'point': out.layer.query.select.type = 'geo.dot'; break; + default: + out.layer.query.select.type = 'geo.' + type; } if (this._sort) { out.layer.style.orderBy = this._sort; diff --git a/readme.md b/readme.md index 97239e3..35556e2 100644 --- a/readme.md +++ b/readme.md @@ -17,7 +17,7 @@ The constructor takes several options, many of them mandatory - `account` - `table` - `host` -- `type`: line or point (only needed if type can't be inferred from table name, i.e. ending with `Line` or `Point` like `conditionLine`). +- `type`: `'line'`, `'point'` or `'markerCluster'` (only needed if type can't be inferred from table name, i.e. ending with `Line` or `Point` like `conditionLine`). - `subdomains`: number of different subdomains, since the domains are zero indexed this is one more then the max subdomain. - `minzoom`: default 0. - `maxzoom`: default 20. @@ -105,3 +105,46 @@ The constructor takes several options, many of them mandatory } ] ``` + +* a cluster ruleset (pre-unified API - July 2016?) + +```json +{ + "styles": [ + { + "range": [ + 0, + 22 + ], + "query": [ + { + "col": "ramp", + "test": "Contains", + "value": "EXIT" + } + ], + "cluster": { + "autoIconEnable": "false", + "clusterCentroid": "location", + "clusterSpacing": 40, + "size": 40, + "text": { + "color": "white", + "size": "9", + "text": "count", + "x": 0, + "y": 0 + }, + "text2": { + "color": "white", + "size": "9", + "text": "count", + "x": 0, + "y": 1 + }, + "url": "https://google.com/clustermarker.png" + } + } + ] +} +```