Skip to content

Commit

Permalink
Add clustering support in map
Browse files Browse the repository at this point in the history
  • Loading branch information
frozenhelium committed Jul 25, 2019
1 parent eb35855 commit 37d20aa
Showing 1 changed file with 25 additions and 8 deletions.
33 changes: 25 additions & 8 deletions components/Visualization/Map/MapSource/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ export default class MapSource extends React.PureComponent {
bounds,
boundsPadding,
images,
cluster,
clusterMaxZoom,
clusterRadius,
} = props;

if (images) {
Expand All @@ -164,19 +167,33 @@ export default class MapSource extends React.PureComponent {
});
}

const properties = {};

// console.info('Adding source', this.props.sourceKey);
if (geoJson) {
map.addSource(sourceKey, {
type: 'geojson',
data: geoJson,
});
properties.type = 'geojson';
properties.data = geoJson;
} else if (url) {
map.addSource(sourceKey, {
type: 'vector',
url,
});
properties.type = 'vector';
properties.url = url;
}

if (cluster) {
properties.cluster = cluster;
}

if (clusterMaxZoom) {
properties.clusterMaxZoom = clusterMaxZoom;
}

if (clusterRadius) {
properties.clusterRadius = clusterRadius;
}

// NOTE: Inject properties for source

map.addSource(sourceKey, properties);

if (bounds) {
map.fitBounds(bounds, { padding: boundsPadding });
}
Expand Down

0 comments on commit 37d20aa

Please sign in to comment.