From 35d41dc6e7049761fb88bfb149a7c8a7c8fd1ad7 Mon Sep 17 00:00:00 2001 From: ingalls Date: Thu, 5 Sep 2024 13:07:44 -0600 Subject: [PATCH] Make map size dynamic --- api/web/src/stores/overlays/base.ts | 11 +++++++++-- api/web/src/stores/overlays/styles.ts | 15 ++++++--------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/api/web/src/stores/overlays/base.ts b/api/web/src/stores/overlays/base.ts index e593fd47d..20f0e8d06 100644 --- a/api/web/src/stores/overlays/base.ts +++ b/api/web/src/stores/overlays/base.ts @@ -7,6 +7,8 @@ import mapgl from 'maplibre-gl' import type { LayerSpecification } from 'maplibre-gl' import cotStyles from './styles.ts' import { std, stdurl } from '../../std.js'; +import { useProfileStore } from '../profile.js'; + /** * @class @@ -157,6 +159,11 @@ export default class Overlay { } } + const profileStore = useProfileStore(); + let size = 8 + if (profileStore.profile.display_text === 'Small') size = 4; + if (profileStore.profile.display_text === 'Large') size = 16; + if (!opts.layers && this.type === 'raster') { opts.layers = [{ 'id': String(this.id), @@ -168,7 +175,7 @@ export default class Overlay { sourceLayer: 'out', group: false, icons: false, - labels: true + labels: { size } }); if (opts.clickable === undefined) { @@ -180,7 +187,7 @@ export default class Overlay { opts.layers = cotStyles(String(this.id), { group: this.mode !== "mission", icons: true, - labels: true + labels: { size } }); if (opts.clickable === undefined) { diff --git a/api/web/src/stores/overlays/styles.ts b/api/web/src/stores/overlays/styles.ts index d8ec4a31d..8ba5b64ef 100644 --- a/api/web/src/stores/overlays/styles.ts +++ b/api/web/src/stores/overlays/styles.ts @@ -10,14 +10,11 @@ import type { export default function styles(id: string, opts: { sourceLayer?: string; group?: boolean; - labels?: boolean; + labels?: { + size: number + }; icons?: boolean; -} = { - sourceLayer: undefined, - group: false, - labels: false, - icons: false -}): Array { +} = {}): Array { const styles: Array = []; const poly: FillLayerSpecification = { @@ -202,8 +199,8 @@ export default function styles(id: string, opts: { 'interpolate', ['linear'], ['zoom'], - 8, 8, - 15, 15 + 8, opts.labels.size, + 15, opts.labels.size + 7 ], 'text-offset': [0, 2], 'text-font': ['Open Sans Bold'],