Skip to content

Commit

Permalink
Merge pull request #431 from HSLdevcom/DT-5714-map
Browse files Browse the repository at this point in the history
DT-5714: Enable matka map
  • Loading branch information
sharhio authored Dec 8, 2023
2 parents 1452ab6 + 577f266 commit 19db01a
Show file tree
Hide file tree
Showing 15 changed files with 729 additions and 112 deletions.
14 changes: 11 additions & 3 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const apiSubscriptionParameter = process.env.API_SUBSCRIPTION_QUERY_PARAMETER_NA

const MAP_URL = process.env.MAP_URL
? process.env.MAP_URL
: 'https://cdn.digitransit.fi/map/v2/hsl-map/{z}/{x}/{y}.png';
: 'https://cdn.digitransit.fi/map/v2';

const __dirname = fileURLToPath(import.meta.url);
const port = process.env.PORT || 3001;
Expand Down Expand Up @@ -83,8 +83,16 @@ app.get('/api/geocoding/:endpoint', (req, res, next) => {
.catch(e => next(e));
});

app.get('/api/map', (req, res) => {
const url = `${MAP_URL}?${apiSubscriptionParameter}`;
app.get('/api/map/:lang', (req, res) => {
const { lang } = req.params
let url;
const hasLang = lang !== 'null' && lang !== 'undefined'
if(hasLang && lang !== 'fi') {
url = `${MAP_URL}/hsl-map-${lang}/{z}/\{x}/{y}.png?${apiSubscriptionParameter}`
} else {
url = `${MAP_URL}/hsl-map/{z}/\{x}/{y}.png?${apiSubscriptionParameter}`

}
return res.status(200).json(url);
});

Expand Down
6 changes: 6 additions & 0 deletions src/MonitorMapContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,17 @@ interface IProps {
modal?: boolean;
updateMap?: (settings: IMapSettings) => void;
topics?: string[];
departures?: any;
lang: string;
}
const MonitorMapContainer: FC<IProps> = ({
preview,
mapSettings,
modal,
updateMap,
topics,
departures,
lang,
}) => {
const [state, setState] = useMergeState({
client: undefined,
Expand Down Expand Up @@ -68,6 +72,8 @@ const MonitorMapContainer: FC<IProps> = ({
clientRef={clientRef}
newTopics={topics}
topicRef={topicRef}
departures={departures}
lang={lang}
/>
</div>
);
Expand Down
4 changes: 2 additions & 2 deletions src/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ const fetchData = (path, options, signal = undefined) => {
};

const monitorAPI = {
getMapSettings(signal = undefined) {
return fetchData('map', {}, signal);
getMapSettings(lang, signal = undefined) {
return fetchData(`map/${lang}`, {}, signal);
},
getPing(signal = undefined) {
const options = {
Expand Down
Loading

0 comments on commit 19db01a

Please sign in to comment.