Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add cluster support (custom types) #2

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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':
Expand All @@ -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;
Expand Down
45 changes: 44 additions & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -105,3 +105,46 @@ The constructor takes several options, many of them mandatory
}
]
```

* a cluster ruleset (pre-unified API - July 2016?)

```json
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is js code not json

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

{
"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"
}
}
]
}
```