mapcomplete/Customizations/LayerDefinition.ts

55 lines
1.7 KiB
TypeScript
Raw Normal View History

2020-07-05 16:59:47 +00:00
import {Tag, TagsFilter} from "../Logic/TagsFilter";
import {UIElement} from "../UI/UIElement";
import {Basemap} from "../Logic/Basemap";
import {ElementStorage} from "../Logic/ElementStorage";
import {UIEventSource} from "../UI/UIEventSource";
import {FilteredLayer} from "../Logic/FilteredLayer";
import {Changes} from "../Logic/Changes";
import {UserDetails} from "../Logic/OsmConnection";
import {TagRenderingOptions} from "./TagRendering";
2020-07-12 21:19:05 +00:00
import {TagDependantUIElementConstructor} from "./UIElementConstructor";
2020-06-23 22:35:19 +00:00
export class LayerDefinition {
2020-07-07 14:00:39 +00:00
/**
* This name is shown in the 'add XXX button'
*/
2020-06-23 22:35:19 +00:00
name: string;
newElementTags: Tag[]
icon: string;
minzoom: number;
overpassFilter: TagsFilter;
2020-07-07 14:00:39 +00:00
/**
* This UIElement is rendered as title element in the popup
*/
2020-07-05 16:59:47 +00:00
title: TagRenderingOptions;
2020-07-07 14:00:39 +00:00
/**
* These are the questions/shown attributes in the popup
*/
2020-07-12 21:19:05 +00:00
elementsToShow: TagDependantUIElementConstructor[];
2020-06-23 22:35:19 +00:00
style: (tags: any) => { color: string, icon: any };
2020-06-28 21:33:48 +00:00
/**
* If an object of the next layer is contained for this many percent in this feature, it is eaten and not shown
*/
maxAllowedOverlapPercentage: number = undefined;
2020-06-23 22:35:19 +00:00
2020-07-01 14:32:17 +00:00
asLayer(basemap: Basemap, allElements: ElementStorage, changes: Changes, userDetails: UIEventSource<UserDetails>, selectedElement: UIEventSource<any>,
showOnPopup: (tags: UIEventSource<(any)>) => UIElement):
2020-06-23 22:35:19 +00:00
FilteredLayer {
return new FilteredLayer(
this.name,
basemap, allElements, changes,
this.overpassFilter,
2020-06-28 21:33:48 +00:00
this.maxAllowedOverlapPercentage,
this.style,
2020-06-29 14:21:36 +00:00
selectedElement,
showOnPopup);
2020-06-23 22:35:19 +00:00
}
}