mapcomplete/Customizations/Layers/BikeShops.ts

74 lines
2.6 KiB
TypeScript
Raw Normal View History

2020-07-20 21:43:42 +00:00
import { LayerDefinition } from "../LayerDefinition";
import Translations from "../../UI/i18n/Translations";
import { Tag } from "../../Logic/TagsFilter";
import FixedText from "../Questions/FixedText";
import { ImageCarouselWithUploadConstructor } from "../../UI/Image/ImageCarouselWithUpload";
import * as L from "leaflet";
import ShopRetail from "../Questions/bike/ShopRetail";
import ShopPump from "../Questions/bike/ShopPump";
import ShopRental from "../Questions/bike/ShopRental";
import ShopRepair from "../Questions/bike/ShopRepair";
2020-07-21 10:14:56 +00:00
import ShopDiy from "../Questions/bike/ShopDiy";
import ShopName from "../Questions/bike/ShopName";
import ShopSecondHand from "../Questions/bike/ShopSecondHand";
import { TagRenderingOptions } from "../TagRendering";
2020-07-20 21:43:42 +00:00
export default class BikeShops extends LayerDefinition {
2020-07-21 10:14:56 +00:00
private readonly sellsBikes = new Tag("service:bicycle:retail", "yes")
private readonly repairsBikes = new Tag("service:bicycle:repair", "yes")
2020-07-20 21:43:42 +00:00
constructor() {
super();
2020-07-21 13:42:55 +00:00
this.name = Translations.t.cyclofix.shop.name.txt
2020-07-21 10:14:56 +00:00
this.icon = "./assets/bike/repair_shop.svg"
2020-07-20 21:43:42 +00:00
this.overpassFilter = new Tag("shop", "bicycle");
this.newElementTags = [
new Tag("shop", "bicycle"),
2020-07-21 10:14:56 +00:00
]
this.maxAllowedOverlapPercentage = 10
2020-07-20 21:43:42 +00:00
this.minzoom = 13;
this.style = this.generateStyleFunction();
2020-07-21 10:14:56 +00:00
this.title = new TagRenderingOptions({
mappings: [
{k: this.sellsBikes, txt: "Bicycle shop"},
2020-07-21 13:42:55 +00:00
{k: new Tag("service:bicycle:retail", "no"), txt: Translations.t.cyclofix.shop.titleRepair},
{k: new Tag("service:bicycle:retail", ""), txt: Translations.t.cyclofix.shop.title},
2020-07-21 10:14:56 +00:00
]
})
2020-07-20 21:43:42 +00:00
this.elementsToShow = [
new ImageCarouselWithUploadConstructor(),
//new ParkingOperator(),
new ShopRetail(),
new ShopRental(),
new ShopRepair(),
new ShopPump(),
2020-07-21 10:14:56 +00:00
new ShopDiy(),
new ShopName(),
new ShopSecondHand()
]
2020-07-20 21:43:42 +00:00
}
private generateStyleFunction() {
const self = this;
2020-07-21 10:14:56 +00:00
return function (tags: any) {
let icon = "assets/bike/repair_shop.svg";
if (self.sellsBikes.matchesProperties(tags)) {
icon = "assets/bike/shop.svg";
}
2020-07-20 21:43:42 +00:00
return {
color: "#00bb00",
icon: L.icon({
iconUrl: self.icon,
2020-07-21 10:14:56 +00:00
iconSize: [50, 50],
iconAnchor: [25, 50]
2020-07-20 21:43:42 +00:00
})
2020-07-21 10:14:56 +00:00
}
}
2020-07-20 21:43:42 +00:00
}
}