Skip to content

Commit

Permalink
Make map size dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Sep 5, 2024
1 parent 26b9e05 commit 35d41dc
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
11 changes: 9 additions & 2 deletions api/web/src/stores/overlays/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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),
Expand All @@ -168,7 +175,7 @@ export default class Overlay {
sourceLayer: 'out',
group: false,
icons: false,
labels: true
labels: { size }
});

if (opts.clickable === undefined) {
Expand All @@ -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) {
Expand Down
15 changes: 6 additions & 9 deletions api/web/src/stores/overlays/styles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<LayerSpecification> {
} = {}): Array<LayerSpecification> {
const styles: Array<LayerSpecification> = [];

const poly: FillLayerSpecification = {
Expand Down Expand Up @@ -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'],
Expand Down

0 comments on commit 35d41dc

Please sign in to comment.