From bcb1feee5f01f77635ff38bcfd04a6ee15a29bb4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladan=20Kudl=C3=A1=C4=8D?= Date: Mon, 25 Jul 2022 20:58:29 +0200 Subject: [PATCH] layers: hide gardens without name (#104) * Use poiLayers in basicStyle * Render only gardens with name --- src/components/Map/styles/basicStyle.ts | 121 +----------------- src/components/Map/styles/layers/poiLayers.ts | 31 ++++- 2 files changed, 32 insertions(+), 120 deletions(-) diff --git a/src/components/Map/styles/basicStyle.ts b/src/components/Map/styles/basicStyle.ts index bf0239fa..b6a80bee 100644 --- a/src/components/Map/styles/basicStyle.ts +++ b/src/components/Map/styles/basicStyle.ts @@ -5,6 +5,7 @@ import { buildings3dBase, buildings3dExtrusion, } from './layers/buildings3dLayers'; +import { poiLayers } from './layers/poiLayers'; import { addHoverPaint } from '../behaviour/featureHover'; import { BACKGROUND, GLYPHS, OSMAPP_SOURCES, OSMAPP_SPRITE } from '../consts'; import { motorwayConstruction } from './layers/contruction'; @@ -2243,125 +2244,6 @@ export const basicStyle = addHoverPaint({ 'text-halo-color': 'rgba(255,255,255,0.7)', }, }, - { - id: 'poi-level-3', - type: 'symbol', - source: 'maptiler_planet', - 'source-layer': 'poi', - minzoom: 16, - filter: ['all', ['==', '$type', 'Point'], ['>=', 'rank', 25]], - layout: { - 'text-padding': 2, - 'text-font': ['Noto Sans Regular'], - 'text-anchor': 'top', - 'icon-image': '{class}_11', - 'text-field': '{name:latin}\n{name:nonlatin}', - 'text-offset': [0, 0.6], - 'text-size': 12, - 'text-max-width': 9, - }, - paint: { - 'text-halo-blur': 0.5, - 'text-color': '#666', - 'text-halo-width': 1, - 'text-halo-color': '#ffffff', - }, - }, - { - id: 'poi-level-2', - type: 'symbol', - source: 'maptiler_planet', - 'source-layer': 'poi', - minzoom: 15, - filter: [ - 'all', - ['==', '$type', 'Point'], - ['<=', 'rank', 24], - ['>=', 'rank', 15], - ], - layout: { - 'text-padding': 2, - 'text-font': ['Noto Sans Regular'], - 'text-anchor': 'top', - 'icon-image': '{class}_11', - 'text-field': '{name:latin}\n{name:nonlatin}', - 'text-offset': [0, 0.6], - 'text-size': 12, - 'text-max-width': 9, - }, - paint: { - 'text-halo-blur': 0.5, - 'text-color': '#666', - 'text-halo-width': 1, - 'text-halo-color': '#ffffff', - }, - }, - { - id: 'poi-level-1', - type: 'symbol', - source: 'maptiler_planet', - 'source-layer': 'poi', - minzoom: 14, - filter: [ - 'all', - ['==', '$type', 'Point'], - ['<=', 'rank', 14], - ['has', 'name'], - ], - layout: { - 'text-padding': 2, - 'text-font': ['Noto Sans Regular'], - 'text-anchor': 'top', - 'icon-image': '{class}_11', - 'text-field': '{name:latin}\n{name:nonlatin}', - 'text-offset': [0, 0.6], - 'text-size': 12, - 'text-max-width': 9, - }, - paint: { - 'text-halo-blur': 0.5, - 'text-color': '#666', - 'text-halo-width': 1, - 'text-halo-color': '#ffffff', - }, - }, - { - id: 'poi-railway', - type: 'symbol', - source: 'maptiler_planet', - 'source-layer': 'poi', - minzoom: 13, - maxzoom: 24, - filter: [ - 'all', - ['==', '$type', 'Point'], - ['has', 'name'], - ['==', 'class', 'railway'], - ['==', 'subclass', 'station'], - ], - layout: { - 'text-padding': 2, - 'text-font': ['Noto Sans Regular'], - 'text-anchor': 'top', - 'icon-image': '{class}_11', - 'text-field': '{name:latin}\n{name:nonlatin}', - 'text-offset': [0, 0.6], - 'text-size': 12, - 'text-max-width': 9, - 'icon-optional': false, - 'icon-ignore-placement': false, - 'icon-allow-overlap': false, - 'text-ignore-placement': false, - 'text-allow-overlap': false, - 'text-optional': true, - }, - paint: { - 'text-halo-blur': 0.5, - 'text-color': '#666', - 'text-halo-width': 1, - 'text-halo-color': '#ffffff', - }, - }, { id: 'highway-name-path', type: 'symbol', @@ -2884,6 +2766,7 @@ export const basicStyle = addHoverPaint({ 'text-halo-color': 'rgba(255,255,255,0.8)', }, }, + ...poiLayers, ], id: 'ciw6czz2n00242kmg6hw20box', }); diff --git a/src/components/Map/styles/layers/poiLayers.ts b/src/components/Map/styles/layers/poiLayers.ts index caa14269..4e7af7f1 100644 --- a/src/components/Map/styles/layers/poiLayers.ts +++ b/src/components/Map/styles/layers/poiLayers.ts @@ -7,7 +7,36 @@ export const poiLayers = [ source: 'maptiler_planet', 'source-layer': 'poi', minzoom: 16, - filter: ['all', ['==', '$type', 'Point'], ['>=', 'rank', 25]], + filter: [ + 'all', + ['==', '$type', 'Point'], + ['>=', 'rank', 25], + ['!=', 'subclass', 'garden'], + ], + layout: { + 'text-padding': 2, + 'text-font': ['Noto Sans Regular'], + 'text-anchor': 'top', + 'icon-image': '{class}_11', + 'text-field': '{name:latin}\n{name:nonlatin}', + 'text-offset': [0, 0.6], + 'text-size': 12, + 'text-max-width': 9, + }, + paint: { + 'text-halo-blur': 0.5, + 'text-color': '#666', + 'text-halo-width': 1, + 'text-halo-color': '#ffffff', + }, + }, + { + id: 'poi-level-3-gardens', + type: 'symbol', + source: 'maptiler_planet', + 'source-layer': 'poi', + minzoom: 16, + filter: ['all', ['==', 'subclass', 'garden'], ['has', 'name']], layout: { 'text-padding': 2, 'text-font': ['Noto Sans Regular'],