diff --git a/src/client/components/facet_results/LeafletMap.js b/src/client/components/facet_results/LeafletMap.js index 511323dd63799893ffe3fe0fac96c12b291a0ee1..5c710b76becf996f1f15944348caa0b952353ce0 100644 --- a/src/client/components/facet_results/LeafletMap.js +++ b/src/client/components/facet_results/LeafletMap.js @@ -29,8 +29,8 @@ import 'leaflet.zoominfo/dist/L.Control.Zoominfo' import 'leaflet.zoominfo/dist/L.Control.Zoominfo.css' import 'leaflet-usermarker/src/leaflet.usermarker.js' import 'leaflet-usermarker/src/leaflet.usermarker.css' -// import 'leaflet.gridlayer.googlemutant/Leaflet.GoogleMutant.js' -// import 'mapbox-gl-leaflet/leaflet-mapbox-gl.js' +// import 'leaflet.gridlayer.googlemutant/Leaflet.GoogleMutant.js' // used for Google Maps basemap +// import 'mapbox-gl-leaflet/leaflet-mapbox-gl.js' // used for National Land Survey of Finland's vectortiles background map import markerShadowIcon from '../../img/markers/marker-shadow.png' import markerIconViolet from '../../img/markers/marker-icon-violet.png' @@ -300,18 +300,23 @@ class LeafletMap extends React.Component { }) /* - Password protected base layers from https://www.maanmittauslaitos.fi/karttakuvapalvelu/tekninen-kuvaus-wmts + Base layers from https://www.maanmittauslaitos.fi/karttakuvapalvelu/tekninen-kuvaus-wmts Routed via backend. */ // const backgroundMapNLS = L.tileLayer(`${process.env.API_URL}/nls-wmts?z={z}&x={x}&y={y}&layerID=taustakartta`, { // attribution: 'National Land Survey of Finland', // maxZoom: 18 // }) - // const topographicalMapNLS = L.tileLayer(`${process.env.API_URL}/nls-wmts?z={z}&x={x}&y={y}&layerID=maastokartta`, { + // https://github.com/mapbox/mapbox-gl-leaflet + // const nlsVectortilesBackgroundmap = L.mapboxGL({ + // accessToken: this.props.mapBoxAccessToken, + // style: `${process.env.API_URL}/nls-vectortiles-open` + // }) + // const topographicalMapNLS = L.tileLayer(`${process.env.API_URL}/nls-wmts-open?z={z}&x={x}&y={y}&layerID=maastokartta`, { // attribution: 'National Land Survey of Finland', // maxZoom: 18 // }) - // const airMapNLS = L.tileLayer(`${process.env.API_URL}/nls-wmts?z={z}&x={x}&y={y}&layerID=ortokuva`, { + // const airMapNLS = L.tileLayer(`${process.env.API_URL}/nls-wmts-open?z={z}&x={x}&y={y}&layerID=ortokuva`, { // attribution: 'National Land Survey of Finland', // maxZoom: 18 // }) @@ -320,12 +325,6 @@ class LeafletMap extends React.Component { // type: 'roadmap' // }) - // https://github.com/mapbox/mapbox-gl-leaflet - // const nlsVectortilesBackgroundmap = L.mapboxGL({ - // accessToken: this.props.mapBoxAccessToken, - // style: `${process.env.API_URL}/nls-vectortiles` - // }) - // layer for markers this.resultMarkerLayer = L.layerGroup() @@ -369,7 +368,7 @@ class LeafletMap extends React.Component { if (this.props.showExternalLayers) { const basemaps = { [intl.get(`leafletMap.basemaps.mapbox.${this.props.mapBoxStyle}`)]: mapboxBaseLayer - // [intl.get('leafletMap.basemaps.backgroundMapNLS')]: nlsVectortilesBackgroundmap + // [intl.get('leafletMap.basemaps.backgroundMapNLS')]: nlsVectortilesBackgroundmap, // [intl.get('leafletMap.basemaps.topographicalMapNLS')]: topographicalMapNLS, // [intl.get('leafletMap.basemaps.airMapNLS')]: airMapNLS // [intl.get('leafletMap.basemaps.googleRoadmap')]: googleRoadmap, diff --git a/src/client/translations/sampo/localeEN.json b/src/client/translations/sampo/localeEN.json index bfa588965ee965d4ef5196f9fec509d5c60edcd0..0355aa28b29975c70b6219869d098741ca2e6f9d 100644 --- a/src/client/translations/sampo/localeEN.json +++ b/src/client/translations/sampo/localeEN.json @@ -131,7 +131,8 @@ }, "googleRoadmap": "Google Maps", "topographicalMapNLS": "Topographical map (National Land Survey of Finland)", - "backgroundMapNLS": "Background map (National Land Survey of Finland)" + "backgroundMapNLS": "Background map (National Land Survey of Finland)", + "airMapNLS": "Aerial map (National Land Survey of Finland)" }, "externalLayers": { "WFS_MV_Kulttuuriymparisto:Arkeologiset_kohteet_alue": "Register of Archaeological Sites, areas (Finnish Heritage Agency)", diff --git a/src/server/index.js b/src/server/index.js index 0ee0d00abe9c8684a57c152efa529b32c6d339bd..3ec11eaf89c01cea66cfabb2c405b603a904d2b2 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -272,8 +272,28 @@ new OpenApiValidator({ } }) + // https://www.maanmittauslaitos.fi/karttakuvapalvelu/tekninen-kuvaus-wmts + app.get(`${apiPath}/nls-wmts-open`, async (req, res, next) => { + const url = `https://avoin-karttakuva.maanmittauslaitos.fi/avoin/wmts/1.0.0/${req.query.layerID}/default/WGS84_Pseudo-Mercator/${req.query.z}/${req.query.y}/${req.query.x}.png` + const headers = { + 'Content-Type': 'image/png', + Authorization: `Basic ${process.env.NLS_API_KEY_BASE64}` + } + try { + const response = await axios({ + method: 'get', + url, + responseType: 'arraybuffer', + headers + }) + res.end(response.data, 'base64') + } catch (error) { + next(error) + } + }) + // // https://www.maanmittauslaitos.fi/karttakuvapalvelu/tekninen-kuvaus-vektoritiilet - app.get(`${apiPath}/nls-vectortiles`, async (req, res, next) => { + app.get(`${apiPath}/nls-vectortiles-open`, async (req, res, next) => { const url = 'https://avoin-karttakuva.maanmittauslaitos.fi/vectortiles/stylejson/v20/taustakartta.json?TileMatrixSet=WGS84_Pseudo-Mercator' const headers = { Authorization: `Basic ${process.env.NLS_API_KEY_BASE64}` diff --git a/src/server/openapi.yaml b/src/server/openapi.yaml index 9349b24a99b4518a801bcd575e23d1128885ef5d..3e3d3dc8831834ab9f8ee13b22e6ae7531771482 100644 --- a/src/server/openapi.yaml +++ b/src/server/openapi.yaml @@ -475,7 +475,7 @@ paths: format: binary /nls-wmts: get: - summary: Route for password protected WMTS layers. + summary: Route for NLS WMTS API. Only for contract customers. parameters: - in: query name: layerID @@ -503,10 +503,41 @@ paths: content: application/json: schema: - type: array - /nls-vectortiles: + type: array + /nls-wmts-open: get: - summary: Route for NLS vectortiles API. + summary: Route for NLS WMTS API, free but requires an API key. + parameters: + - in: query + name: layerID + schema: + type: string + required: true + - in: query + name: x + schema: + type: string + required: true + - in: query + name: y + schema: + type: string + required: true + - in: query + name: z + schema: + type: string + required: true + responses: + '200': + description: An array of GeoJSON layers. + content: + application/json: + schema: + type: array + /nls-vectortiles-open: + get: + summary: Route for NLS vectortiles API, free but requires an API key. responses: '200': description: Styles for vector tiles as JSON