2021-05-02 13:24:27 -04:00
|
|
|
import * as React from 'react';
|
|
|
|
import { TileLayer } from 'react-leaflet';
|
|
|
|
|
|
|
|
import { MapTheme } from '../../config/map-config';
|
|
|
|
|
2021-05-06 13:53:57 -04:00
|
|
|
const OS_API_KEY = 'UVWEspgInusDKKYANE5bmyddoEmCSD4r';
|
2021-05-02 13:24:27 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Base raster layer for the map.
|
|
|
|
* @param theme map theme
|
|
|
|
*/
|
2021-07-17 17:49:38 -04:00
|
|
|
export function CityBaseMapLayer({ theme }: { theme: MapTheme }) {
|
2021-05-02 13:24:27 -04:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Ordnance Survey maps - UK / London specific
|
|
|
|
* (replace with appropriate base map for other cities/countries)
|
|
|
|
*/
|
2021-05-06 13:53:57 -04:00
|
|
|
const apiKey = OS_API_KEY;
|
2021-07-17 17:49:38 -04:00
|
|
|
|
|
|
|
// Note that OS APIs does not provide dark theme
|
2021-12-08 11:50:49 -05:00
|
|
|
const layer = 'Light_3857';
|
2021-07-17 17:49:38 -04:00
|
|
|
|
|
|
|
// In either theme case, we will use OS's light theme, but add our own filter
|
|
|
|
const theme_class = theme === 'light' ? "light-theme" : "night-theme";
|
|
|
|
|
2021-05-06 13:53:57 -04:00
|
|
|
const baseUrl = `https://api.os.uk/maps/raster/v1/zxy/${layer}/{z}/{x}/{y}.png?key=${apiKey}`;
|
2021-05-02 13:24:27 -04:00
|
|
|
const attribution = 'Building attribute data is © Colouring London contributors. Maps contain OS data © Crown copyright: OS Maps baselayers and building outlines. <a href=/ordnance-survey-licence.html>OS licence</a>';
|
2021-07-17 17:49:38 -04:00
|
|
|
|
2021-05-02 13:24:27 -04:00
|
|
|
return <TileLayer
|
|
|
|
url={baseUrl}
|
|
|
|
attribution={attribution}
|
|
|
|
maxNativeZoom={18}
|
|
|
|
maxZoom={19}
|
|
|
|
detectRetina={true}
|
2021-07-17 17:49:38 -04:00
|
|
|
className={theme_class}
|
2021-05-02 13:24:27 -04:00
|
|
|
/>;
|
|
|
|
}
|
|
|
|
|