forked from MapComplete/MapComplete
Automatically cluster maps with more then 250 elements
This commit is contained in:
parent
46b05d7410
commit
4dacfd157a
5 changed files with 19 additions and 13 deletions
|
@ -25,7 +25,8 @@ export default class LayoutConfig {
|
|||
public readonly defaultBackgroundId?: string;
|
||||
public readonly layers: LayerConfig[];
|
||||
public readonly clustering?: {
|
||||
maxZoom: number
|
||||
maxZoom: number,
|
||||
minNeededElements: number
|
||||
};
|
||||
|
||||
public readonly hideFromOverview: boolean;
|
||||
|
@ -89,21 +90,22 @@ export default class LayoutConfig {
|
|||
});
|
||||
|
||||
|
||||
this.clustering = undefined;
|
||||
this.clustering = {
|
||||
maxZoom: 16,
|
||||
minNeededElements: 250
|
||||
};
|
||||
if(json.clustering){
|
||||
this.clustering = {
|
||||
maxZoom : json.clustering.maxZoom ?? 18
|
||||
maxZoom : json.clustering.maxZoom ?? 18,
|
||||
minNeededElements: json.clustering.minNeededElements ?? 1
|
||||
}
|
||||
}
|
||||
|
||||
if(this.clustering){
|
||||
for (const layer of this.layers) {
|
||||
if(layer.wayHandling !== LayerConfig.WAYHANDLING_CENTER_ONLY){
|
||||
console.error("WARNING: In order to allow clustering, every layer must be set to CENTER_ONLY. Layer", layer.id,"does not respect this for layout",this.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
this.hideFromOverview = json.hideFromOverview ?? false;
|
||||
|
||||
this.enableUserBadge = json.enableUserBadge ?? true;
|
||||
|
|
|
@ -128,9 +128,15 @@ export interface LayoutConfigJson {
|
|||
*/
|
||||
clustering?: {
|
||||
/**
|
||||
* All zoom levels above 'maxzoom' are not clustered anymore
|
||||
* All zoom levels above 'maxzoom' are not clustered anymore.
|
||||
* Defaults to 18
|
||||
*/
|
||||
maxZoom?: number
|
||||
maxZoom?: number,
|
||||
/**
|
||||
* The number of elements that should be showed (in total) before clustering starts to happen.
|
||||
* If clustering is defined, defaults to 0
|
||||
*/
|
||||
minNeededElements?: number
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue