Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding MapTiles API as a tile provider #448

Merged
merged 4 commits into from
Sep 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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