From d465a272f2bea2556b108ecb62e06c39dcce9b09 Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 14 Jun 2023 00:47:09 +0200 Subject: [PATCH] Feature: add Americana background style, fix #1204 --- Models/RasterLayerProperties.ts | 1 + Models/RasterLayers.ts | 20 +++++++++++++++++++- UI/Map/MapLibreAdaptor.ts | 6 ++++++ 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/Models/RasterLayerProperties.ts b/Models/RasterLayerProperties.ts index 2686ebe2a..e489f76c4 100644 --- a/Models/RasterLayerProperties.ts +++ b/Models/RasterLayerProperties.ts @@ -19,6 +19,7 @@ export interface RasterLayerProperties { readonly url: string readonly category?: string | EliCategory + readonly type?: "vector" | string readonly attribution?: { readonly url?: string diff --git a/Models/RasterLayers.ts b/Models/RasterLayers.ts index e549c6a13..617f3f7cb 100644 --- a/Models/RasterLayers.ts +++ b/Models/RasterLayers.ts @@ -44,6 +44,7 @@ export class AvailableRasterLayers { url: "https://api.maptiler.com/maps/15cc8f61-0353-4be6-b8da-13daea5f7432/style.json?key=GvoVAJgu46I5rZapJuAy", category: "osmbasedmap", id: "maptiler", + type: "vector", attribution: { text: "Maptiler", url: "https://www.maptiler.com/copyright/" @@ -52,6 +53,22 @@ export class AvailableRasterLayers { geometry: BBox.global.asGeometry(), } + public static readonly americana: RasterLayerPolygon = { + type: "Feature", + properties: { + name: "Americana", + url: "https://zelonewolf.github.io/openstreetmap-americana/style.json", + category: "osmbasedmap", + id: "americana", + type: "vector", + attribution: { + text: "Americana", + url: "https://github.com/ZeLonewolf/openstreetmap-americana/" + } + }, + geometry: BBox.global.asGeometry(), + } + public static layersAvailableAt( location: Store<{ lon: number; lat: number }> ): Store { @@ -74,6 +91,7 @@ export class AvailableRasterLayers { return GeoOperations.inside(lonlat, eliPolygon) }) matching.unshift(AvailableRasterLayers.osmCarto) + matching.unshift(AvailableRasterLayers.americana) matching.unshift(AvailableRasterLayers.maplibre) matching.push(...AvailableRasterLayers.globalLayers) return matching @@ -133,7 +151,7 @@ export interface EditorLayerIndexProperties extends RasterLayerProperties { * Whether the imagery name should be translated */ readonly i18n?: boolean - readonly type: "tms" | "wms" | "bing" | "scanex" | "wms_endpoint" | "wmts" + readonly type: "tms" | "wms" | "bing" | "scanex" | "wms_endpoint" | "wmts" | "vector" /* Vector is not actually part of the ELI-spec, we add it for vector layers */ /** * A rough categorisation of different types of layers. See https://github.com/osmlab/editor-layer-index/blob/gh-pages/CONTRIBUTING.md#categories for a description of the individual categories. */ diff --git a/UI/Map/MapLibreAdaptor.ts b/UI/Map/MapLibreAdaptor.ts index 5dd5871af..d69170a68 100644 --- a/UI/Map/MapLibreAdaptor.ts +++ b/UI/Map/MapLibreAdaptor.ts @@ -379,6 +379,12 @@ export class MapLibreAdaptor implements MapProperties, ExportableMap { return } + if(background.type === "vector"){ + console.log("Background layer is vector") + map.setStyle(background.url) + return + } + map.addSource(background.id, MapLibreAdaptor.prepareWmsSource(background)) map.resize()