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

[Feature] Add support for the clusterProperties and clusterMinPoints options #119

Merged
merged 5 commits into from
Sep 14, 2023
Merged
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
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@ All notable changes to this project will be documented in this file. The format

## [Unreleased]

### Added

- Add support for the `clusterProperties` option ([4a55844](https://github.com/studiometa/vue-mapbox-gl/commit/4a55844), [#119](https://github.com/studiometa/vue-mapbox-gl/pull/119), fix [#117](https://github.com/studiometa/vue-mapbox-gl/issues/117))
- Add support for the `clusterMinPoints` option ([4e403c7](https://github.com/studiometa/vue-mapbox-gl/commit/4e403c7), [#119](https://github.com/studiometa/vue-mapbox-gl/pull/119))

### Fixed

- Fix a bug where the geolocate control could be accessed before being added to the map ([3f8eaef](https://github.com/studiometa/vue-mapbox-gl/commit/3f8eaef), [#106](https://github.com/studiometa/vue-mapbox-gl/pull/106), fix [#77](https://github.com/studiometa/vue-mapbox-gl/issues/77))
Expand Down
16 changes: 15 additions & 1 deletion packages/docs/components/MapboxCluster/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,21 @@ The max zoom to cluster points on.
- Type `Number`
- Default `50`

Radius of each cluster when clustering point
Radius of each cluster when clustering point.

### `clusterMinPoints`

- Type `Number`
- Default `2`

Minimum number of points necessary to form a cluster.

### `clusterProperties`

- Type `Object`
- Default `{}}`

An object defining custom properties on the generated clusters.

### `clustersLayout`

Expand Down
22 changes: 21 additions & 1 deletion packages/vue-mapbox-gl/components/MapboxCluster.vue
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,24 @@
type: Number,
default: 50,
},
/**
* Minimum number of points necessary to form a cluster.
* @type {number}
*/
clusterMinPoints: {
type: Number,
default: 2,
},
/**
* An object defining custom properties on the generated clusters.
* @see https://docs.mapbox.com/style-spec/reference/sources/#geojson-clusterProperties
* @see https://docs.mapbox.com/mapbox-gl-js/example/cluster-html/
* @type {object}
*/
clusterProperties: {
type: Object,
default: () => ({}),
},
/**
* The layout configuration for the clusters circles
* @see https://docs.mapbox.com/mapbox-gl-js/example/cluster/
Expand Down Expand Up @@ -140,13 +158,15 @@

const sourceId = computed(() => getId('source'));
const source = computed(() => {
const { data, clusterMaxZoom, clusterRadius } = props;
const { data, clusterMaxZoom, clusterRadius, clusterMinPoints, clusterProperties } = props;
return {
type: 'geojson',
cluster: true,
data,
clusterMaxZoom,
clusterRadius,
clusterMinPoints,
clusterProperties,
};
});

Expand Down
Loading