forked from MapComplete/MapComplete
Expose clustering in layoutConfig
This commit is contained in:
parent
27f2206cae
commit
c548c26158
7 changed files with 40 additions and 16 deletions
|
@ -24,7 +24,9 @@ export default class LayoutConfig {
|
|||
public readonly roamingRenderings: TagRenderingConfig[];
|
||||
public readonly defaultBackgroundId?: string;
|
||||
public readonly layers: LayerConfig[];
|
||||
public readonly clustering: { };
|
||||
public readonly clustering?: {
|
||||
maxZoom: number
|
||||
};
|
||||
|
||||
public readonly hideFromOverview: boolean;
|
||||
public readonly enableUserBadge: boolean;
|
||||
|
@ -76,22 +78,28 @@ export default class LayoutConfig {
|
|||
);
|
||||
this.defaultBackgroundId = json.defaultBackgroundId;
|
||||
this.layers = json.layers.map((layer, i) => {
|
||||
if (typeof layer === "string")
|
||||
if (typeof layer === "string"){
|
||||
if (SharedLayers.sharedLayers[layer] !== undefined) {
|
||||
return SharedLayers.sharedLayers[layer];
|
||||
} else {
|
||||
throw "Unkown fixed layer " + layer;
|
||||
}
|
||||
}
|
||||
return new LayerConfig(layer, this.roamingRenderings, `${this.id}.layers[${i}]`);
|
||||
});
|
||||
|
||||
|
||||
this.clustering = json.clustering ?? false;
|
||||
this.clustering = undefined;
|
||||
if(json.clustering){
|
||||
this.clustering = {
|
||||
maxZoom : json.clustering.maxZoom ?? 18
|
||||
}
|
||||
}
|
||||
|
||||
if(this.clustering){
|
||||
for (const layer of this.layers) {
|
||||
if(layer.wayHandling !== LayerConfig.WAYHANDLING_CENTER_ONLY){
|
||||
throw "In order to allow clustering, every layer must be set to 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -126,7 +126,10 @@ export interface LayoutConfigJson {
|
|||
/**
|
||||
* If defined, data will be clustered.
|
||||
*/
|
||||
clustering: {
|
||||
clustering: {
|
||||
/**
|
||||
* All zoom levels above 'maxzoom' are not clustered anymore
|
||||
*/
|
||||
maxZoom?: number
|
||||
},
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue