Skip to content

Commit 65241e6

Browse files
lesbaaLes Moffat
andauthored
RD-1218 Upgrade Streets, Landscape and add Base v4 styles, deprecate respective v2 versions. (#68)
* RD-1218 - Upgrade `Streets`, `Landscape` to v4 - Add new `Base` style - Add functionality for custom deprecation warning. * RD-1218 Remove console.log --------- Co-authored-by: Les Moffat <les.moffat@maptiler.com>
1 parent 50a099b commit 65241e6

File tree

2 files changed

+184
-24
lines changed

2 files changed

+184
-24
lines changed

CHANGELOG.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
11
# MapTiler Client Changelog
22

3+
## NEXT
4+
### New Features
5+
- Bumps 'Streets' & 'Landscape' styles (and their variants) to new v4 styles.
6+
- Adds the new 'Base' style and its variants.
7+
8+
### Bug Fixes
9+
None
10+
11+
### Others
12+
- Adds custom deprecation warnings.
13+
- Deprecates the older v2 styles and adds warnings regarding their usage.
14+
315
## 2.5.1
416
### New Features
517
None

src/mapstyle.ts

Lines changed: 172 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ export type MapStylePreset = {
3232
description: string;
3333
variants: Array<{
3434
deprecated?: boolean;
35+
deprecationMessage?: string;
3536
id: string;
3637
name: string;
3738
variantType: string;
@@ -79,6 +80,11 @@ export class MapStyleVariant {
7980
* Whether this variant is deprecated or not
8081
*/
8182
public deprecated: boolean = false,
83+
84+
/**
85+
* Message to display when the variant is deprecated
86+
*/
87+
public deprecationMessage?: string,
8288
) {}
8389

8490
/**
@@ -178,12 +184,15 @@ export class MapStyleVariant {
178184

179185
warnIfDeprecated(variant: MapStyleVariant = this): MapStyleVariant {
180186
if (!variant.deprecated) return variant;
181-
182-
const name = variant.getFullName();
183-
184-
console.warn(
185-
`Style "${name}" is deprecated and will be removed in a future version.`,
186-
);
187+
188+
if (variant.deprecationMessage) {
189+
console.warn(variant.deprecationMessage);
190+
} else {
191+
const name = variant.getFullName();
192+
console.warn(
193+
`Style "${name}" is deprecated and will be removed in a future version.`,
194+
);
195+
}
187196

188197
return variant;
189198
}
@@ -286,26 +295,59 @@ export type MapStyleType = {
286295
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings
287296
*/
288297
STREETS: ReferenceMapStyle & {
298+
289299
/**
290300
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings.
291-
*/
301+
*/
292302
DEFAULT: MapStyleVariant;
293303
/**
294304
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in dark mode.
295305
*/
296306
DARK: MapStyleVariant;
297307
/**
298-
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in light mode.
308+
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, with a pastel color palette.
299309
*/
300-
LIGHT: MapStyleVariant;
310+
PASTEL: MapStyleVariant;
311+
301312
/**
302-
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, in blue night mode.
313+
* Streets v2 is deprecated, use streets v4 instead
303314
*/
304-
NIGHT: MapStyleVariant;
315+
DEFAULT_V2: MapStyleVariant;
305316
/**
306-
* Suitable for navigation, with high level of detail on urban areas, plenty of POIs and 3D buildings, with a pastel color palette.
317+
* Streets v2 is deprecated, use streets v4-dark instead
307318
*/
308-
PASTEL: MapStyleVariant;
319+
DARK_V2: MapStyleVariant;
320+
/**
321+
* Streets v2 is deprecated, use streets v4-light instead
322+
*/
323+
LIGHT_V2: MapStyleVariant;
324+
/**
325+
* Streets v2 is deprecated, use streets v4-night instead
326+
*/
327+
NIGHT_V2: MapStyleVariant;
328+
/**
329+
* Streets v2 is deprecated, use streets v4-pastel instead
330+
*/
331+
PASTEL_V2: MapStyleVariant;
332+
};
333+
334+
BASE: ReferenceMapStyle & {
335+
/**
336+
* Light and informative map, for general use.
337+
*/
338+
DEFAULT: MapStyleVariant;
339+
/**
340+
* Darker version of the base style, for night use.
341+
*/
342+
DARK: MapStyleVariant;
343+
/**
344+
* Light version of the base style, for day use.
345+
*/
346+
LIGHT: MapStyleVariant;
347+
/**
348+
* A clear and informative map, for general use.
349+
*/
350+
AI: MapStyleVariant;
309351
};
310352

311353
/**
@@ -539,6 +581,18 @@ export type MapStyleType = {
539581
* Vivid terrain map for data overlays and visualisations
540582
*/
541583
VIVID: MapStyleVariant;
584+
/**
585+
* Default v2 is deprecated, use DEFAULT instead
586+
*/
587+
DEFAULT_V2: MapStyleVariant;
588+
/**
589+
* Dark v2 is deprecated, use DARK instead
590+
*/
591+
DARK_V2: MapStyleVariant;
592+
/**
593+
* Vivid v2 is deprecated, use VIVID instead
594+
*/
595+
VIVID_V2: MapStyleVariant;
542596
};
543597
/**
544598
* Watercolor map for creative use
@@ -566,37 +620,104 @@ export const mapStylePresetList: Array<MapStylePreset> = [
566620
description: "",
567621
variants: [
568622
{
569-
id: "streets-v2",
623+
id: "streets-v4",
570624
name: "Default",
571625
variantType: "DEFAULT",
572626
description: "",
573627
imageURL: "",
574628
},
575629
{
576-
id: "streets-v2-dark",
630+
id: "streets-v4-dark",
577631
name: "Dark",
578632
variantType: "DARK",
579633
description: "",
580634
imageURL: "",
581635
},
636+
{
637+
id: "streets-v4-pastel",
638+
name: "Pastel",
639+
variantType: "PASTEL",
640+
description: "",
641+
imageURL: "",
642+
},
643+
{
644+
id: "streets-v2",
645+
name: "Default v2",
646+
variantType: "DEFAULT_V2",
647+
description: "",
648+
imageURL: "",
649+
deprecated: true,
650+
deprecationMessage: `"streets-v2" is deprecated, use "streets-v4" instead`,
651+
},
652+
{
653+
id: "streets-v2-dark",
654+
name: "Dark v2",
655+
variantType: "DARK_V2",
656+
description: "",
657+
imageURL: "",
658+
deprecated: true,
659+
deprecationMessage: `"streets-v2-dark" is deprecated, use "streets-v4-dark" instead`,
660+
},
582661
{
583662
id: "streets-v2-light",
584-
name: "Light",
585-
variantType: "LIGHT",
663+
name: "Light v2",
664+
variantType: "LIGHT_V2",
586665
description: "",
587666
imageURL: "",
667+
deprecated: true,
668+
deprecationMessage: `"streets-v2-light" is deprecated, use "streets-v4-light" instead`,
588669
},
589670
{
590671
id: "streets-v2-night",
591-
name: "Night",
592-
variantType: "NIGHT",
672+
name: "Night v2",
673+
variantType: "NIGHT_V2",
593674
description: "",
594675
imageURL: "",
676+
deprecated: true,
677+
deprecationMessage: `"streets-v2-night" is deprecated, use "streets-v4-night" instead`,
595678
},
596679
{
597680
id: "streets-v2-pastel",
598-
name: "Pastel",
599-
variantType: "PASTEL",
681+
name: "Pastel v2",
682+
variantType: "PASTEL_V2",
683+
description: "",
684+
imageURL: "",
685+
deprecated: true,
686+
deprecationMessage: `"streets-v2-pastel" is deprecated, use "streets-v4-pastel" instead`,
687+
},
688+
],
689+
},
690+
691+
{
692+
referenceStyleID: "BASE",
693+
name: "Base",
694+
description: "",
695+
variants: [
696+
{
697+
id: "base-v4",
698+
name: "Default",
699+
variantType: "DEFAULT",
700+
description: "",
701+
imageURL: "",
702+
},
703+
{
704+
id: "base-v4-dark",
705+
name: "Dark",
706+
variantType: "DARK",
707+
description: "",
708+
imageURL: "",
709+
},
710+
{
711+
id: "base-v4-light",
712+
name: "Light",
713+
variantType: "LIGHT",
714+
description: "",
715+
imageURL: "",
716+
},
717+
{
718+
id: "base-v4-ai",
719+
name: "Night",
720+
variantType: "NIGHT",
600721
description: "",
601722
imageURL: "",
602723
},
@@ -984,26 +1105,53 @@ export const mapStylePresetList: Array<MapStylePreset> = [
9841105
description: "Terrain map for data overlays and visualisations",
9851106
variants: [
9861107
{
987-
id: "landscape",
1108+
id: "landscape-v4",
9881109
name: "Default",
9891110
variantType: "DEFAULT",
9901111
description: "",
9911112
imageURL: "",
9921113
},
9931114
{
994-
id: "landscape-dark",
1115+
id: "landscape-v4-dark",
9951116
name: "Dark",
9961117
variantType: "DARK",
9971118
description: "",
9981119
imageURL: "",
9991120
},
10001121
{
1001-
id: "landscape-vivid",
1122+
id: "landscape-v4-vivid",
10021123
name: "Vivid",
10031124
variantType: "VIVID",
10041125
description: "",
10051126
imageURL: "",
10061127
},
1128+
{
1129+
id: "landscape",
1130+
name: "Default",
1131+
variantType: "DEFAULT_V2",
1132+
description: "",
1133+
imageURL: "",
1134+
deprecated: true,
1135+
deprecationMessage: `"landscape" is deprecated, use "landscape-v4" instead`,
1136+
},
1137+
{
1138+
id: "landscape-dark",
1139+
name: "Dark",
1140+
variantType: "DARK_V2",
1141+
description: "",
1142+
imageURL: "",
1143+
deprecated: true,
1144+
deprecationMessage: `"landscape-dark" is deprecated, use "landscape-v4-dark" instead`,
1145+
},
1146+
{
1147+
id: "landscape-vivid",
1148+
name: "Vivid",
1149+
variantType: "VIVID_V2",
1150+
description: "",
1151+
imageURL: "",
1152+
deprecated: true,
1153+
deprecationMessage: `"landscape-vivid" is deprecated, use "landscape-v4-vivid" instead`,
1154+
},
10071155
],
10081156
},
10091157
];

0 commit comments

Comments
 (0)