Skip to content
This repository was archived by the owner on Feb 10, 2025. It is now read-only.

Commit c1e8c88

Browse files
committed
Replace mapbox with palvelukartta-iframe
- removes react-map-gl, mapbox-gl and mapboxToken
1 parent 6114526 commit c1e8c88

11 files changed

Lines changed: 21 additions & 432 deletions

File tree

apps/ui/README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@ See `.env.local.example` and Azure DevOps library for values.
4343
| NEXT_PUBLIC_BASE_URL | application baseUrl |
4444
| TILAVARAUS_API_URL | tilavaraus-core base url |
4545
| PROFILE_UI_URL | helsinki profile frontend url for a link |
46-
| MAPBOX_TOKEN | token tor mapbox service |
4746
| SENTRY_DSN | Sentry dsn |
4847
| SENTRY_ENVIRONMENT | Sentry environment, for example 'test', 'prod' |
4948
| SENTRY_AUTH_TOKEN | auth token for sentry cli |

apps/ui/components/Map.tsx

Lines changed: 12 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,65 +1,23 @@
1-
import React, { useState } from "react";
2-
import Image from "next/image";
3-
import ReactMapGL, { Marker, NavigationControl, ViewState } from "react-map-gl";
4-
import { mapStyle } from "../modules/const";
5-
import "mapbox-gl/dist/mapbox-gl.css";
1+
import React from "react";
2+
import { useTranslation } from "next-i18next";
3+
import { mapUrlPrefix } from "@/modules/const";
64

75
type Props = {
8-
title: string;
9-
mapboxToken: string;
10-
latitude?: number;
11-
longitude?: number;
6+
tprekId: string;
127
height?: string;
138
};
14-
const ZOOM = 14;
15-
16-
const navControlStyle = {
17-
right: 10,
18-
bottom: 10,
19-
};
209

2110
export const Map = ({
22-
title,
23-
latitude,
24-
longitude,
11+
tprekId,
2512
height = "480px",
26-
mapboxToken,
2713
}: Props): JSX.Element | null => {
28-
const [viewport, setViewport] = useState({
29-
latitude,
30-
longitude,
31-
zoom: ZOOM,
32-
} as ViewState);
33-
34-
if (!latitude || !longitude) {
35-
return null;
36-
}
37-
14+
const { t, i18n } = useTranslation();
15+
const mapUrl = `${mapUrlPrefix}${i18n.language}/embed/unit/${tprekId}`;
3816
return (
39-
<ReactMapGL
40-
{...viewport}
41-
id="hel-osm-light"
42-
mapStyle={mapStyle}
43-
style={{ width: "100%", height }}
44-
onMove={(event) => {
45-
setViewport(event.viewState);
46-
}}
47-
initialViewState={{
48-
longitude,
49-
latitude,
50-
zoom: ZOOM,
51-
}}
52-
mapboxAccessToken={mapboxToken}
53-
>
54-
<Marker
55-
key={title}
56-
longitude={longitude}
57-
latitude={latitude}
58-
anchor="bottom"
59-
>
60-
<NavigationControl style={navControlStyle} showCompass={false} />
61-
<Image src="/icons/map_marker_icon.svg" height="42" width="32" alt="" />
62-
</Marker>
63-
</ReactMapGL>
17+
<iframe
18+
title={t("reservationUnit:mapTitle")}
19+
style={{ border: "none", width: "100%", height }}
20+
src={mapUrl}
21+
/>
6422
);
6523
};

apps/ui/components/reservation-unit/Address.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { IconLinkExternal } from "hds-react";
77
import { IconButton } from "common/src/components";
88
import type { ReservationUnitNode } from "common";
99
import { getTranslation } from "../../modules/util";
10+
import { mapUrlPrefix } from "@/modules/const";
1011

1112
type Props = {
1213
reservationUnit: ReservationUnitNode;
@@ -87,7 +88,7 @@ function createMapUrl(locale: string, unit?: Maybe<UnitType>): string {
8788
return "";
8889
}
8990

90-
return `https://palvelukartta.hel.fi/${locale}/unit/${unit.tprekId}`;
91+
return `${mapUrlPrefix}${locale}/unit/${unit.tprekId}`;
9192
}
9293

9394
function createAccessibilityUrl(

apps/ui/modules/const.ts

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { i18n } from "next-i18next";
22
import { OptionType } from "common/types/common";
3-
import { MapboxStyle } from "react-map-gl";
43

54
export { isBrowser } from "common/src/helpers";
65
export { getSignInUrl, getSignOutUrl } from "common/src/urlBuilder";
@@ -16,26 +15,7 @@ export const reservationsPrefix = "/reservations";
1615
export const criteriaPrefix = "/criteria";
1716
export const parametersPrefix = "/parameters";
1817

19-
export const mapStyle: MapboxStyle = {
20-
version: 8,
21-
name: "hel-osm-light",
22-
metadata: {},
23-
sources: {
24-
osm: {
25-
type: "raster",
26-
tiles: ["https://tiles.hel.ninja/styles/hel-osm-light/{z}/{x}/{y}.png"],
27-
minzoom: 0,
28-
maxzoom: 20,
29-
},
30-
},
31-
layers: [
32-
{
33-
id: "osm",
34-
type: "raster",
35-
source: "osm",
36-
},
37-
],
38-
};
18+
export const mapUrlPrefix = "https://palvelukartta.hel.fi/";
3919

4020
export const reservationUnitPath = (id: number): string =>
4121
`${reservationUnitPrefix}/${id}`;

apps/ui/modules/serverUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,15 +16,13 @@ export function getCommonServerSideProps() {
1616
const hotjarEnabled = env.HOTJAR_ENABLED ?? false;
1717
const profileLink = env.PROFILE_UI_URL ?? "";
1818
const apiBaseUrl = env.TILAVARAUS_API_URL ?? "";
19-
const mapboxToken = env.MAPBOX_TOKEN ?? "";
2019

2120
return {
2221
cookiehubEnabled,
2322
matomoEnabled,
2423
hotjarEnabled,
2524
profileLink,
2625
apiBaseUrl,
27-
mapboxToken,
2826
};
2927
}
3028

apps/ui/package.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
"hds-react": "^2.17.1",
3232
"i18next": "^23.10.1",
3333
"lodash": "^4.17.21",
34-
"mapbox-gl": "^3.2.0",
3534
"next": "14.1.4",
3635
"next-compose-plugins": "^2.2.1",
3736
"next-i18next": "^15.2.0",
@@ -42,7 +41,6 @@
4241
"react-dom": "18.2.0",
4342
"react-hook-form": "^7.51.2",
4443
"react-i18next": "^14.1.0",
45-
"react-map-gl": "^7.1.7",
4644
"react-transition-group": "^4.4.5",
4745
"react-use": "^17.5.0",
4846
"sanitize-html": "^2.13.0",
@@ -62,7 +60,6 @@
6260
"@types/node": "^18.18.8",
6361
"@types/react": "18.0.27",
6462
"@types/react-dom": "18.0.10",
65-
"@types/react-map-gl": "^6.1.6",
6663
"@types/react-transition-group": "^4.4.10",
6764
"@types/sanitize-html": "^2.11.0",
6865
"@types/styled-components": "^5.1.29",

apps/ui/pages/reservation-unit/[id].tsx

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -377,7 +377,6 @@ const ReservationUnit = ({
377377
activeApplicationRounds,
378378
termsOfUse,
379379
isPostLogin,
380-
mapboxToken,
381380
apiBaseUrl,
382381
}: PropsNarrowed): JSX.Element | null => {
383382
const { t, i18n } = useTranslation();
@@ -1089,18 +1088,13 @@ const ReservationUnit = ({
10891088
</PaddedContent>
10901089
</Accordion>
10911090
)}
1092-
{reservationUnit.unit?.location && (
1091+
{reservationUnit.unit?.tprekId && (
10931092
<Accordion heading={t("common:location")} theme="thin" open>
10941093
<JustForMobile customBreakpoint={breakpoints.l}>
10951094
<AddressSection reservationUnit={reservationUnit} />
10961095
</JustForMobile>
10971096
<MapWrapper>
1098-
<Map
1099-
title={getTranslation(reservationUnit.unit, "name")}
1100-
latitude={Number(reservationUnit.unit.location.latitude)}
1101-
longitude={Number(reservationUnit.unit.location.longitude)}
1102-
mapboxToken={mapboxToken}
1103-
/>
1097+
<Map tprekId={reservationUnit.unit?.tprekId ?? ""} />
11041098
</MapWrapper>
11051099
</Accordion>
11061100
)}

apps/ui/public/locales/en/reservationUnit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"maxDuration": "Duration",
66
"price": "Price",
77
"billableHours": "Chargeable hours",
8+
"mapTitle": "Service Map - location",
89
"linkMap": "Open map in a new window",
910
"linkHSL": "HSL Route Guide",
1011
"linkGoogle": "Google Directions",

apps/ui/public/locales/fi/reservationUnit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"maxDuration": "Varauksen kesto",
66
"price": "Hinta",
77
"billableHours": "Maksulliset tunnit",
8+
"mapTitle": "Palvelukartta - sijainti",
89
"linkMap": "Avaa kartta uuteen ikkunaan",
910
"linkHSL": "HSL Reittiopas",
1011
"linkGoogle": "Google reittiohjeet",

apps/ui/public/locales/sv/reservationUnit.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
"maxDuration": "Bokningens varaktighet",
66
"price": "Pris",
77
"billableHours": "Avgiftsbelagda timmar",
8+
"mapTitle": "Servicekarta - verksamhetsställe",
89
"linkMap": "Öppna kartan i ett nytt fönster",
910
"linkHSL": "HRT Reseplaneraren",
1011
"linkGoogle": "Google vägbeskrivningar",

0 commit comments

Comments
 (0)