From c2bc38adeafecaf4f44cef0c97a6429cbddf50ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rn=20Lund?= Date: Sat, 1 Feb 2020 13:03:46 +0100 Subject: [PATCH] Introduce HEREv3 (#343) * Add HERE API v3 - Tile API URL changed - Authorization by apiKey * Update README (HEREv3) * Readme: Remove link to Available HERE layers --- README.md | 14 ++++-- leaflet-providers.js | 110 ++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 119 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 151b2f20..3b4c7644 100644 --- a/README.md +++ b/README.md @@ -29,9 +29,17 @@ Leaflet-providers provides tile layers from different providers, including *Open In addition to the providers you are free1 to use, we support some layers which require registration. -### HERE (formerly Nokia). +### HERE and HEREv3 (formerly Nokia). -In order to use HERE layers, you must [register](http://developer.here.com/). Once registered, you can create an `app_id` and `app_code` which you have to pass to `L.tileLayer.provider` in the options: +In order to use HEREv3 layers, you must [register](http://developer.here.com/). Once registered, you can create an `apiKey` which you have to pass to `L.tileLayer.provider` in the options: + +```Javascript +L.tileLayer.provider('HEREv3.terrainDay', { + apiKey: '' +}).addTo(map); +``` + +You can still pass `app_id` and `app_code` in legacy projects: ```Javascript L.tileLayer.provider('HERE.terrainDay', { @@ -40,8 +48,6 @@ L.tileLayer.provider('HERE.terrainDay', { }).addTo(map); ``` -[Available HERE layers](http://leaflet-extras.github.io/leaflet-providers/preview/#filter=HERE) - ### Mapbox In order to use Mapbox maps, you must [register](https://tiles.mapbox.com/signup). You can get map_ID (i.e mapbox.satellite) and ACCESS_TOKEN from [Mapbox projects](https://www.mapbox.com/projects): diff --git a/leaflet-providers.js b/leaflet-providers.js index 08de17ef..208b6257 100644 --- a/leaflet-providers.js +++ b/leaflet-providers.js @@ -494,7 +494,7 @@ HERE: { /* * HERE maps, formerly Nokia maps. - * These basemaps are free, but you need an API key. Please sign up at + * These basemaps are free, but you need an api id and app key. Please sign up at * https://developer.here.com/plans */ url: @@ -610,6 +610,114 @@ } } }, + HEREv3: { + /* + * HERE maps API Version 3. + * These basemaps are free, but you need an API key. Please sign up at + * https://developer.here.com/plans + * Version 3 deprecates the app_id and app_code access in favor of apiKey + * + * Supported access methods as of 2019/12/21: + * @see https://developer.here.com/faqs#access-control-1--how-do-you-control-access-to-here-location-services + */ + url: + 'https://{s}.{base}.maps.ls.hereapi.com/maptile/2.1/' + + '{type}/{mapID}/{variant}/{z}/{x}/{y}/{size}/{format}?' + + 'apiKey={apiKey}&lg={language}', + options: { + attribution: + 'Map © 1987-' + new Date().getFullYear() + ' HERE', + subdomains: '1234', + mapID: 'newest', + apiKey: '', + base: 'base', + variant: 'normal.day', + maxZoom: 20, + type: 'maptile', + language: 'eng', + format: 'png8', + size: '256' + }, + variants: { + normalDay: 'normal.day', + normalDayCustom: 'normal.day.custom', + normalDayGrey: 'normal.day.grey', + normalDayMobile: 'normal.day.mobile', + normalDayGreyMobile: 'normal.day.grey.mobile', + normalDayTransit: 'normal.day.transit', + normalDayTransitMobile: 'normal.day.transit.mobile', + normalNight: 'normal.night', + normalNightMobile: 'normal.night.mobile', + normalNightGrey: 'normal.night.grey', + normalNightGreyMobile: 'normal.night.grey.mobile', + normalNightTransit: 'normal.night.transit', + normalNightTransitMobile: 'normal.night.transit.mobile', + reducedDay: 'reduced.day', + reducedNight: 'reduced.night', + basicMap: { + options: { + type: 'basetile' + } + }, + mapLabels: { + options: { + type: 'labeltile', + format: 'png' + } + }, + trafficFlow: { + options: { + base: 'traffic', + type: 'flowtile' + } + }, + carnavDayGrey: 'carnav.day.grey', + hybridDay: { + options: { + base: 'aerial', + variant: 'hybrid.day' + } + }, + hybridDayMobile: { + options: { + base: 'aerial', + variant: 'hybrid.day.mobile' + } + }, + hybridDayTransit: { + options: { + base: 'aerial', + variant: 'hybrid.day.transit' + } + }, + hybridDayGrey: { + options: { + base: 'aerial', + variant: 'hybrid.grey.day' + } + }, + pedestrianDay: 'pedestrian.day', + pedestrianNight: 'pedestrian.night', + satelliteDay: { + options: { + base: 'aerial', + variant: 'satellite.day' + } + }, + terrainDay: { + options: { + base: 'aerial', + variant: 'terrain.day' + } + }, + terrainDayMobile: { + options: { + base: 'aerial', + variant: 'terrain.day.mobile' + } + } + } + }, FreeMapSK: { url: 'http://t{s}.freemap.sk/T/{z}/{x}/{y}.jpeg', options: {