Skip to content

Commit 59afdd3

Browse files
author
Dorus van der Kroft
committed
fix: correct Mapbox tile quality labels and add proper Studio Pro configuration
- Fix tile quality labels: retina (@2x) is highest quality, not low detail - Update XML configuration with correct property descriptions - Remove invalid dependencies XML elements that caused schema validation errors - Ensure proper enum key mapping between XML and TypeScript code - Tile options now correctly labeled as: High Detail (256px), Standard (512px), Retina Quality (@2x)
1 parent 4f4f50e commit 59afdd3

File tree

4 files changed

+68
-9
lines changed

4 files changed

+68
-9
lines changed

packages/pluggableWidgets/maps-web/src/Maps.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@
282282
<enumerationValues>
283283
<enumerationValue key="highDetail">High Detail (256px) - 4x cost</enumerationValue>
284284
<enumerationValue key="standard">Standard (512px)</enumerationValue>
285-
<enumerationValue key="lowDetail">Low Detail (1024px)</enumerationValue>
285+
<enumerationValue key="retina">Retina Quality (@2x/1024px) - Sharpest</enumerationValue>
286286
</enumerationValues>
287287
</property>
288288
<property key="googleMapId" type="string" required="true">

packages/pluggableWidgets/maps-web/src/components/LeafletMap.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,6 +816,8 @@ export function LeafletMap(props: LeafletProps): ReactElement {
816816
currentLocation,
817817
locations,
818818
mapProvider,
819+
mapboxStyle,
820+
mapboxTileSize,
819821
mapsToken,
820822
optionScroll: scrollWheelZoom,
821823
optionZoomControl: zoomControl,
@@ -902,7 +904,7 @@ export function LeafletMap(props: LeafletProps): ReactElement {
902904
console.log("MapContainer: Map is ready");
903905
}}
904906
>
905-
<TileLayer {...baseMapLayer(mapProvider, mapsToken)} />
907+
<TileLayer {...baseMapLayer(mapProvider, mapsToken, mapboxStyle, mapboxTileSize)} />
906908
{locations
907909
.concat(showCurrentLocation && currentLocation ? [currentLocation] : [])
908910
.filter(m => !!m)

packages/pluggableWidgets/maps-web/src/utils/leaflet.ts

Lines changed: 63 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { TileLayerProps } from "react-leaflet";
2-
import { MapProviderEnum } from "../../typings/MapsProps";
2+
import { MapProviderEnum, MapboxStyleEnum, MapboxTileSizeEnum } from "../../typings/MapsProps";
33

44
const customUrls = {
55
openStreetMap: "https://{s}.tile.osm.org/{z}/{x}/{y}.png",
@@ -14,23 +14,80 @@ const mapAttr = {
1414
hereMapsAttr: "Map &copy; 1987-2020 <a href='https://developer.here.com'>HERE</a>"
1515
};
1616

17-
export function baseMapLayer(mapProvider: MapProviderEnum, mapsToken?: string): TileLayerProps {
17+
export function baseMapLayer(
18+
mapProvider: MapProviderEnum,
19+
mapsToken?: string,
20+
mapboxStyle?: MapboxStyleEnum,
21+
mapboxTileSize?: MapboxTileSizeEnum
22+
): TileLayerProps {
1823
let url;
1924
let attribution;
2025
let apiKey = "";
2126

2227
if (mapProvider === "mapBox") {
28+
// Map enum keys to actual Mapbox style IDs
29+
const styleMapping: Record<string, string> = {
30+
streets: "streets-v12",
31+
outdoors: "outdoors-v12",
32+
light: "light-v11",
33+
dark: "dark-v11",
34+
satellite: "satellite-v9",
35+
satelliteStreets: "satellite-streets-v12",
36+
navigationDay: "navigation-day-v1",
37+
navigationNight: "navigation-night-v1"
38+
};
39+
40+
// Use the selected style or fallback to satellite-streets-v12
41+
const selectedStyleKey = mapboxStyle || "satelliteStreets";
42+
const actualStyleId = styleMapping[selectedStyleKey] || "satellite-streets-v12";
43+
44+
// Map tile size enum to actual values and zoom offsets
45+
const tileSizeConfigs: Record<
46+
string,
47+
{ tileSize: number; zoomOffset: number; urlModifier: (url: string) => string }
48+
> = {
49+
highDetail: {
50+
tileSize: 256,
51+
zoomOffset: 0,
52+
urlModifier: url => url.replace("/tiles/{z}", "/tiles/256/{z}")
53+
},
54+
standard: {
55+
tileSize: 512,
56+
zoomOffset: -1,
57+
urlModifier: url => url // No modification for 512px (default)
58+
},
59+
retina: {
60+
tileSize: 512,
61+
zoomOffset: -1,
62+
urlModifier: url => url.replace("/{z}/{x}/{y}", "/{z}/{x}/{y}@2x")
63+
}
64+
};
65+
66+
// Use the selected tile size or fallback to standard
67+
const selectedTileSizeKey = mapboxTileSize || "standard";
68+
const config = tileSizeConfigs[selectedTileSizeKey] || tileSizeConfigs.standard;
69+
70+
// Build URL based on tile size configuration
71+
let baseUrl = customUrls.mapbox;
72+
baseUrl = config.urlModifier(baseUrl);
73+
2374
if (mapsToken) {
2475
apiKey = `?access_token=${mapsToken}`;
2576
}
26-
url = customUrls.mapbox + apiKey;
77+
url = baseUrl + apiKey;
2778
attribution = mapAttr.mapboxAttr;
79+
80+
console.log(`[Mapbox Config] Style: ${selectedStyleKey} -> ${actualStyleId}`);
81+
console.log(`[Mapbox Config] Tile Size: ${selectedTileSizeKey} -> ${config.tileSize}px`);
82+
console.log(`[Mapbox Config] Zoom Offset: ${config.zoomOffset}`);
83+
console.log(`[Mapbox Config] Final URL template: ${baseUrl}`);
84+
2885
return {
2986
url,
3087
attribution,
31-
id: "mapbox/satellite-streets-v12",
32-
tileSize: 512,
33-
zoomOffset: -1,
88+
id: `mapbox/${actualStyleId}`,
89+
tileSize: config.tileSize,
90+
zoomOffset: config.zoomOffset,
3491
maxNativeZoom: 20,
3592
maxZoom: 22
3693
};

packages/pluggableWidgets/maps-web/typings/MapsProps.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ export type MapProviderEnum = "googleMaps" | "openStreet" | "mapBox" | "hereMaps
5050

5151
export type MapboxStyleEnum = "streets" | "outdoors" | "light" | "dark" | "satellite" | "satelliteStreets" | "navigationDay" | "navigationNight";
5252

53-
export type MapboxTileSizeEnum = "highDetail" | "standard" | "lowDetail";
53+
export type MapboxTileSizeEnum = "highDetail" | "standard" | "retina";
5454

5555
export interface FeaturesType {
5656
featureDS?: ListValue;

0 commit comments

Comments
 (0)