Skip to content

Commit

Permalink
fix cluster aggregates
Browse files Browse the repository at this point in the history
  • Loading branch information
Savina Shen (Manpower Services Taiwan Co Ltd) committed Aug 20, 2024
1 parent 5a64095 commit 7d1885e
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ Clustered points have four properties;
- `point_count` - The number of points the cluster contains.
- `point_count_abbreviated` - A string that abbreviates the point_count value if it is long. (i.e. 4,000 becomes 4K)

For more information on clustering, see the tutorial [here](https://learn.microsoft.com/en-us/azure/azure-maps/clustering-point-data-web-sdk).

You can observe the clusters by zooming in and out on the map.

<ClusterAggregates showBubbles showNumbers/>

In this example, we use a **Bubble Layer** to render the clusters as circles and a **Symbol Layer** to render the number of points in each cluster.
For the bubble layer, we set the radius and the color to change based on the number of points in the cluster.
For the bubble layer, we set the radius and the color to change based on the numbers of points in the clusters.

<Source code={`
const bubbleLayerOptions = {
//Scale the size of the clustered bubble based on the number of points inthe cluster.
//Scale the size of the clustered bubble based on the number of points in the cluster.
radius: [
'step',
['get', 'point_count'],
Expand All @@ -47,7 +49,7 @@ const bubbleLayerOptions = {
};
`}/>

For the symbol layer, we set the text to be the point_count_abbreviated property of the cluster.
For the symbol layer, we set the text to be the `point_count_abbreviated` property of the cluster.

<Source code={`
const symbolLayerOptions = {
Expand All @@ -71,11 +73,11 @@ import {
AzureMapsProvider,
} from 'react-azure-maps';
const ClusterAggregates = ({ showBubbles, showNumbers }: ClusterAggregatesProps) => {
const ClusterAggregates = () => {
return (
<AzureMapsProvider>
<AzureMap options={your_option}>
<AzureMap options={...your_options, center: [-97, 39], zoom: 1.5, view: 'Auto',}>
<AzureMapDataSourceProvider
id="ClusterAggregates DataSourceProvider"
dataFromUrl="https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_month.geojson"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,15 @@ import {
AzureMapsProvider,
IAzureMapOptions,
} from 'react-azure-maps';
import { AuthenticationType } from 'azure-maps-control';
import { key } from '../../../key';
import { mapOptions } from '../../../key';

export interface ClusterAggregatesProps {
showBubbles: boolean;
showNumbers: boolean;
}

const option: IAzureMapOptions = {
authOptions: {
authType: AuthenticationType.subscriptionKey,
subscriptionKey: key,
},
...mapOptions,
center: [-97, 39],
zoom: 1.5,
view: 'Auto',
Expand Down

0 comments on commit 7d1885e

Please sign in to comment.