Skip to content

Commit 0aa3a43

Browse files
author
farah-alyasari
committed
reviewed clustering point data web sdk. resolved 12 issues. improved overall score by 6 points - style improved from 83 to 100. clarity improved from 75 to 91. tone improved from 83 to 88.
1 parent 06202f6 commit 0aa3a43

File tree

1 file changed

+18
-14
lines changed

1 file changed

+18
-14
lines changed

articles/azure-maps/clustering-point-data-web-sdk.md

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Clustering point data on a map | Microsoft Azure Maps
3-
description: In this article, you will learn how to cluster point data and render it on a map using the Microsoft Azure Maps Web SDK.
3+
description: In this article, you'll learn how to cluster point data and render it on a map using the Microsoft Azure Maps Web SDK.
44
author: rbrundritt
55
ms.author: richbrun
66
ms.date: 07/29/2019
@@ -13,15 +13,15 @@ ms.custom: codepen
1313

1414
# Clustering point data
1515

16-
When visualizing many data points on the map, points overlap each other, the map looks cluttered and it becomes difficult to see and use. Clustering of point data can be used to improve this user experience. Clustering point data is the process of combining point data that are near each other and representing them on the map as a single clustered data point. As the user zooms into the map, the clusters break apart into their individual data points.
16+
When visualizing many data points on the map, data points may overlap over each other. The overlap may cause the map may become unreadable and difficult to use. Clustering point data is the process of combining point data that are near each other and representing them on the map as a single clustered data point. As the user zooms into the map, the clusters break apart into their individual data points. When you work with large number of data points, use the clustering processes to improve your user experience.
1717

1818
<br/>
1919

2020
<iframe src="https://channel9.msdn.com/Shows/Internet-of-Things-Show/Clustering-point-data-in-Azure-Maps/player" width="960" height="540" allowFullScreen frameBorder="0"></iframe>
2121

2222
## Enabling clustering on a data source
2323

24-
Clustering can easily be enabled on the `DataSource` class by setting the `cluster` option to true. Additionally, the pixel radius to select nearby points to combine into a cluster can be set using the `clusterRadius` and a zoom level can be specified at which to disable the clustering logic using the `clusterMaxZoom` option. Here is an example of how to enable clustering in a data source.
24+
Enable clustering in the `DataSource` class by setting the `cluster` option to true. Set `ClusterRadius` to selects nearby points and combines them into a cluster. The value of `ClusterRadius` is in pixels. Use `clusterMaxZoom` to Specify a zoom level at which to disable the clustering logic. Here is an example of how to enable clustering in a data source.
2525

2626
```javascript
2727
//Create a data source and enable clustering.
@@ -39,9 +39,9 @@ var datasource = new atlas.source.DataSource(null, {
3939
```
4040

4141
> [!TIP]
42-
> If two data points are close together on the ground, it is possible the cluster will never break apart, no matter how close the user zooms in. To address this, you can set the `clusterMaxZoom` option of the data source which specifies at the zoom level to disable the clustering logic and simply display everything.
42+
> If two data points are close together on the ground, it's possible the cluster will never break apart, no matter how close the user zooms in. To address this, you can set the `clusterMaxZoom` option to disable the clustering logic and simply display everything.
4343
44-
The `DataSource` class also has the following methods related to clustering:
44+
Here are additional methods that the `DataSource` class provides for clustering:
4545

4646
| Method | Return type | Description |
4747
|--------|-------------|-------------|
@@ -51,7 +51,9 @@ The `DataSource` class also has the following methods related to clustering:
5151

5252
## Display clusters using a bubble layer
5353

54-
A bubble layer is a great way to render clustered points as you can easily scale the radius and change the color them based on the number of points in the cluster by using an expression. When displaying clusters using a bubble layer, you should also use a separate layer for rendering unclustered data points. It is often nice to also be able to display the size of the cluster on top of the bubbles. A symbol layer with text and no icon can be used to achieve this behavior.
54+
A bubble layer is a great way to render clustered points. Use expressions to scale the radius and change the color based on the number of points in the cluster. If you display clusters using a bubble layer, then you should use a separate layer to render unclustered data points.
55+
56+
To display the size of the cluster on top of the bubble, use a symbol layer with text, and don't use an icon.
5557

5658
<br/>
5759

@@ -62,7 +64,9 @@ A bubble layer is a great way to render clustered points as you can easily scale
6264

6365
## Display clusters using a symbol layer
6466

65-
When visualizing the point data using the Symbol layer, by default it will automatically hide symbols that overlap each other to create a cleaner experience, however this may not be the desired experience if you want to see the density of data points on the map. Setting the `allowOverlap` option of the Symbol layers `iconOptions` property to `true` disables this experience but will result in all the symbols being displayed. Using clustering allows you to see the density of all the data while creating a nice clean user experience. In this sample, custom symbols will be used to represent clusters and individual data points.
67+
When visualizing data points, the symbol layer automatically hides symbols that overlap each other to ensure a cleaner user interface. This default behavior might be undesirable if you want to show the data points density on the map. However, these settings can be changed. To display all symbols, set the `allowOverlap` option of the Symbol layers `iconOptions` property to `true`.
68+
69+
Use clustering to show the data points density while keeping a clean user interface. The sample below shows you how to add custom symbols and represent clusters and individual data points using the symbol layer.
6670

6771
<br/>
6872

@@ -73,7 +77,7 @@ When visualizing the point data using the Symbol layer, by default it will autom
7377

7478
## Clustering and the heat maps layer
7579

76-
Heat maps are a great way to display the density of data on the map. This visualization can handle a large number of data points on its own, but it can handle even more data if the data points are clustered and the cluster size is used as the weight of the heat map. Set the `weight` option of the heat map layer to `['get', 'point_count']` to achieve this. When the cluster radius is small, the heat map will look nearly identical to a heat map using the unclustered data points but will perform much better. However, the smaller the cluster radius, the more accurate the heat map will be but with less of a performance benefit.
80+
Heat maps are a great way to display the density of data on the map. This visualization method can handle a large number of data points on its own. If the data points are clustered and the cluster size is used as the weight of the heat map, then the heat map can handle even more data. To achieve this option, set the `weight` option of the heat map layer to `['get', 'point_count']`. When the cluster radius is small, the heat map will look nearly identical to a heat map using the unclustered data points, but it will perform much better. However, the smaller the cluster radius, the more accurate the heat map will be, but with fewer performance benefits.
7781

7882
<br/>
7983

@@ -84,16 +88,16 @@ Heat maps are a great way to display the density of data on the map. This visual
8488

8589
## Mouse events on clustered data points
8690

87-
When mouse events occur on a layer that contain clustered data points, the clustered data point will be returned to the event as a GeoJSON point feature object. This point feature will have the following properties:
91+
When mouse events occur on a layer that contains clustered data points, the clustered data point return to the event as a GeoJSON point feature object. This point feature will have the following properties:
8892

8993
| Property name | Type | Description |
9094
|---------------------------|---------|---------------|
9195
| `cluster` | boolean | Indicates if feature represents a cluster. |
9296
| `cluster_id` | string | A unique ID for the cluster that can be used with the DataSource `getClusterExpansionZoom`, `getClusterChildren`, and `getClusterLeaves` methods. |
9397
| `point_count` | number | The number of points the cluster contains. |
94-
| `point_count_abbreviated` | string | A string that abbreviates the `point_count` value if it is long. (for example, 4,000 becomes 4K) |
98+
| `point_count_abbreviated` | string | A string that abbreviates the `point_count` value if it's long. (for example, 4,000 becomes 4K) |
9599

96-
This example takes a bubble layer that renders cluster points and adds a click event that when triggered, calculate, and zoom the map to the next zoom level at which the cluster will break apart using the `getClusterExpansionZoom` method of the `DataSource` class and the `cluster_id` property of the clicked clustered data point.
100+
This example takes a bubble layer that renders cluster points and adds a click event. When the click event triggers, the code calculates and zooms the map to the next zoom level, at which the cluster breaks apart. This functionality is implemented using the `getClusterExpansionZoom` method of the `DataSource` class and the `cluster_id` property of the clicked clustered data point.
97101

98102
<br/>
99103

@@ -104,7 +108,7 @@ This example takes a bubble layer that renders cluster points and adds a click e
104108

105109
## Display cluster area
106110

107-
The point data that a cluster represents is spread over an area. In this sample when the mouse is hovered over a cluster, the individual data points it contains (leaves) will be used to calculate a convex hull and displayed on the map to show the area. All points contained in a cluster can be retrieved from the data source using the `getClusterLeaves` method. A convex hull is a polygon that wraps a set of points like an elastic band and can be calculated using the `atlas.math.getConvexHull` method.
111+
The point data that a cluster represents is spread over an area. In this sample when the mouse is hovered over a cluster, two main behaviors occur. First, the individual data points contained in the cluster will be used to calculate a convex hull. Then, the convex hull will be displayed on the map to show an area. A convex hull is a polygon that wraps a set of points like an elastic band and can be calculated using the `atlas.math.getConvexHull` method. All points contained in a cluster can be retrieved from the data source using the `getClusterLeaves` method.
108112

109113
<br/>
110114

@@ -115,9 +119,9 @@ The point data that a cluster represents is spread over an area. In this sample
115119

116120
## Aggregating data in clusters
117121

118-
Often clusters are represented using a symbol with the number of points that are within the cluster, however sometimes it is desirable to further customize the style of clusters based on some metric, like the total revenue of all points within a cluster. With cluster aggregates custom properties can be created and populated using an [aggregate expression](data-driven-style-expressions-web-sdk.md#aggregate-expression) calculation. Cluster aggregates can be defined in `clusterProperties` option of the `DataSource`.
122+
Often clusters are represented using a symbol with the number of points that are within the cluster. But, sometimes it's desirable to customize the style of clusters with additional metrics. With cluster aggregates, custom properties can be created and populated using an [aggregate expression](data-driven-style-expressions-web-sdk.md#aggregate-expression) calculation. Cluster aggregates can be defined in `clusterProperties` option of the `DataSource`.
119123

120-
The following sample uses an aggregate expression to calculate a count based on the entity type property of each data point in a cluster.
124+
The following sample uses an aggregate expression. The code calculates a count based on the entity type property of each data point in a cluster. When a user clicks on a cluster, a popup shows with additional information about the cluster.
121125

122126
<iframe height="500" style="width: 100%;" scrolling="no" title="Cluster aggregates" src="//codepen.io/azuremaps/embed/jgYyRL/?height=500&theme-id=0&default-tab=js,result" frameborder="no" allowtransparency="true" allowfullscreen="true">
123127
See the Pen <a href='https://codepen.io/azuremaps/pen/jgYyRL/'>Cluster aggregates</a> by Azure Maps

0 commit comments

Comments
 (0)