Skip to content

Commit

Permalink
Adding MapTiles API as a tile provider (#448)
Browse files Browse the repository at this point in the history
Adding MapTiles API examples, a provider for global maps in one language (English, French or Spanish).

Added example api key for MapTiles API. This key is not to be used in production by third parties but just for leaflet-providers.
Added three OpenStreetMap Language versions provided by MapTilesAPI.
Added example for MapTiles API, which requires an apikey.
  • Loading branch information
MapTilesAPI authored Sep 10, 2022
1 parent 3b7bd4f commit 939a966
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@ L.tileLayer.provider('MapTiler.Streets', {
}).addTo(map);
```

### MapTiles API

In order to use OpenStreetMap in English, French or Spanish provided by MapTiles API, you must [register](https://www.maptilesapi.com/). Once registered, you have to add your key to `L.tileLayer.provider` in the options:
```JavaScript
L.tileLayer.provider('MapTilesAPI.OSMEnglish', {
apikey: '<insert key here>'
}).addTo(map);
```

### Thunderforest

In order to use Thunderforest maps, you must [register](https://thunderforest.com/pricing/). Once registered, you have an `api_key` which you have to pass to `L.tileLayer.provider` in the options:
Expand Down
3 changes: 3 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@
'OpenStreetMap Default': defaultLayer,
'OpenStreetMap German Style': L.tileLayer.provider('OpenStreetMap.DE'),
'OpenStreetMap H.O.T.': L.tileLayer.provider('OpenStreetMap.HOT'),
'MapTilesAPI OpenStreetMap in English': L.tileLayer.provider('MapTilesAPI.OSMEnglish'),
'MapTilesAPI OpenStreetMap en Français': L.tileLayer.provider('MapTilesAPI.OSMFrancais'),
'MapTilesAPI OpenStreetMap en Español': L.tileLayer.provider('MapTilesAPI.OSMEspagnol'),
'Thunderforest OpenCycleMap': L.tileLayer.provider('Thunderforest.OpenCycleMap'),
'Thunderforest Transport': L.tileLayer.provider('Thunderforest.Transport'),
'Thunderforest Landscape': L.tileLayer.provider('Thunderforest.Landscape'),
Expand Down
29 changes: 29 additions & 0 deletions leaflet-providers.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,35 @@
}
}
},
MapTilesAPI: {
url: 'https://maptiles.p.rapidapi.com/{variant}/{z}/{x}/{y}.png?rapidapi-key={apikey}',
options: {
attribution:
'&copy; <a href="http://www.maptilesapi.com/">MapTiles API</a>, {attribution.OpenStreetMap}',
variant: 'en/map/v1',
// Get your own MapTiles API access token here : https://www.maptilesapi.com/
// NB : this is a demonstration key that comes with no guarantee and not to be used in production
apikey: '<insert your api key here>',
maxZoom: 19
},
variants: {
OSMEnglish: {
options: {
variant: 'en/map/v1'
}
},
OSMFrancais: {
options: {
variant: 'fr/map/v1'
}
},
OSMEspagnol: {
options: {
variant: 'es/map/v1'
}
}
}
},
OpenSeaMap: {
url: 'https://tiles.openseamap.org/seamark/{z}/{x}/{y}.png',
options: {
Expand Down
3 changes: 3 additions & 0 deletions preview/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ var exampleAPIcodes = {
'Jawg': {
'accessToken': 'PyTJUlEU1OPJwCJlW1k0NC8JIt2CALpyuj7uc066O7XbdZCjWEL3WYJIk6dnXtps'
},
'MapTilesAPI': {
'apikey': '91eb180eb9msh46beac27e6084cep17a106jsn18a17417dbb6'
},
'Thunderforest': {
'apikey': 'db5ae1f5778a448ca662554581f283c5'
}
Expand Down

0 comments on commit 939a966

Please sign in to comment.