Detalhes do pacote

leaflet-providers

leaflet-extras32kBSD-2-Clause2.0.0

An extension to Leaflet that contains configurations for various free tile providers.

readme (leia-me)

Leaflet-providers

An extension to Leaflet that contains configurations for various free1 tile providers.

Installation

Download leaflet-providers.js and include it in your page after including Leaflet, e.g.:

<head>
  ...
  <script src="http://unpkg.com/leaflet@latest/dist/leaflet.js"></script>
  <script src="js/leaflet-providers.js"></script>
</head>

Usage

Leaflet-providers providers are referred to with a provider[.<variant>]-string. Let's say you want to add the nice Watercolor style from Stamen to your map, you pass Stadia.StamenWatercolor to the L.tileLayer.provider-constructor, which will return a L.TileLayer instance for Stamens Watercolor tile layer.

// add Stamen Watercolor to map.
L.tileLayer.provider('Stadia.StamenWatercolor').addTo(map);

Providers

Leaflet-providers provides tile layers from different providers, including OpenStreetMap, Esri and OpenWeatherMap. The full listing of free to use layers can be previewed. The page will show you the name to use with leaflet-providers.js and the code to use it without dependencies.

Providers requiring registration

In addition to the providers you are free1 to use, we support some layers which require registration.

HERE and HEREv3 (formerly Nokia).

In order to use HEREv3 layers, you must register. Once registered, you can create an apiKey which you have to pass to L.tileLayer.provider in the options:

L.tileLayer.provider('HEREv3.terrainDay', {
    apiKey: '<insert apiKey here>'
}).addTo(map);

You can still pass app_id and app_code in legacy projects:

L.tileLayer.provider('HERE.terrainDay', {
    app_id: '<insert ID here>',
    app_code: '<insert ID here>'
}).addTo(map);

Jawg Maps

In order to use Jawg Maps, you must register. Once registered, your access token will be located here and you will access to all Jawg default maps (variants) and your own customized maps :

L.tileLayer.provider('Jawg.Streets', {
    variant: '<insert map id here or blank for default variant>',
    accessToken: '<insert access token here>'
}).addTo(map);

Mapbox

In order to use Mapbox maps, you must register. You can get map_ID (e.g. "mapbox/satellite-v9") and ACCESS_TOKEN from Mapbox projects:

L.tileLayer.provider('MapBox', {
    id: '<insert map_ID here>',
    accessToken: '<insert ACCESS_TOKEN here>'
}).addTo(map);

The currently-valid Mapbox map styles, to use for map_IDs, are listed in the Mapbox documentation - only the final part of each is required, e.g. "mapbox/light-v10".

MapTiler Cloud

In order to use MapTiler maps, you must register. Once registered, get your API key from Account->Keys, which you have to pass to L.tileLayer.provider in the options:

L.tileLayer.provider('MapTiler.Streets', {
    key: '<insert key here>'
}).addTo(map);

MapTiles API

In order to use OpenStreetMap in English, French or Spanish provided by MapTiles API, you must register. Once registered, you have to add your key to L.tileLayer.provider in the options:

L.tileLayer.provider('MapTilesAPI.OSMEnglish', {
    apikey: '<insert key here>'
}).addTo(map);

Thunderforest

In order to use Thunderforest maps, you must register. Once registered, you have an api_key which you have to pass to L.tileLayer.provider in the options:

L.tileLayer.provider('Thunderforest.Landscape', {apikey: '<insert api_key here>'}).addTo(map);

Esri/ArcGIS

In order to use ArcGIS maps, you must register and abide by the terms of service. No special syntax is required.

Available Esri layers

TomTom

In order to use TomTom layers, you must register. Once registered, you can create an apikey which you have to pass to L.tileLayer.provider in the options:

L.tileLayer.provider('TomTom', {
    apikey: '<insert your API key here>'
}).addTo(map);

Geoportail France

In order to use Geoportail France resources, you need to obtain an api key that allows you to access the resources you need. Pass this api key and the ID of the resource to display to L.tileLayer.provider in the options:

L.tileLayer.provider('GeoportailFrance', {
    variant: '<insert resource ID here>',
    apikey: '<insert api key here>'
}).addTo(map);

Please note that a public api key (choisirgeoportail) is used by default and comes with no guarantee.

4 aliases are also provided for common Geoportail resources : GeoportailFrance, GeoportailFrance.orthos, GeoportailFrance.ignMaps and GeoportailFrance.parcels (See index.html demo).

Stadia Maps

In order to use Stadia maps, you must register. Once registered, you can whitelist your domain within your account settings.

Stamen Design

As of July 31, 2023, Stamen's map styles are now hosted by Stadia Maps. You can read the full announcement from Stamen here. No code changes are required to continue using Stamen map styles hosted by Stadia Maps. Simply register and whitelist your domain.

Attribution

This work was inspired from https://gist.github.com/1804938, and originally created by Stefan Seelmann.

What do we mean by free?

1 We try to maintain leaflet-providers in such a way that you'll be able to use the layers we include without paying money. This doesn't mean no limits apply, you should always check before using these layers for anything serious.

changelog (log de mudanças)

Leaflet-providers changelog

2.0.0 (2023-08-28)

  • Update provider url for BasemapAT to new url scheme #522
  • [Breaking] Move Stamen styles to reflect that they are now hosted by Stadia Maps #520
  • Remove subdomains for openstreetmap.de #515
  • Update Esri.OceanBasemap endpoint #493
  • Adding MapTiles API as a tile provider #448
  • Remove subdomains for tile.openstreetmap.org #472
  • [Breaking] Remove Hydda layers #351
  • Add Swiss Federal Geoportal map tiles #426
  • Update NL Maps endpoint and variants #410

1.13.0 (2021-10-19)

  • Add Azure Maps Tiles provider #384
  • Fix nlmaps attribution link #386
  • Update nlmaps.luchtfoto tiles url #390
  • Update NASAGIBS.ModisTerraSnowCover tiles url #391
  • Upgrade dependencies, add dependabot for npm/github actions #392
  • Switch JusticeMap and OpenAIP to https, remove GeoportailFrance.ignMaps from index.html #393
  • Replace OpenPtMap overlay by OPNVKarte layer #396
  • Updated maxzoom for CartoDB #403
  • Multiple dependencies updated by @dependabot

1.12.0 (2021-04-02)

  • Add OpenAIP map provider #374
  • Migrate from travis to github actions #375
  • Fix typo in OpenStreetMap France attribution #378
  • Add OpenSnowMap map provider #379
  • Improve Geoportail resources #382
  • Remove Wikimedia map provider #383

1.11.0 (2020-11-16)

  • Update example Mapbox map_ID #365
  • Add USGS National Map tiles #367
  • Update preview libs and use leaflet 1.7.1 #370
  • Add Waymarked Trails overlay provider #373

1.10.2 (2020-07-31)

  • Update mversion dep #357
  • Mention stadia resitration in in README.md
  • Update freemap.sk tiles url #359
  • Switch unpkg resources to https on demo page #361
  • Update demo page and test pages to leaflet 1.6.0
  • New (non dev) URLs for CyclOSM tiles #363

1.10.1 (2020-05-18)

  • Exclude MapTiler from demo
  • Refine #348 : don't put jawg token in dist file

1.10.0 (2020-05-17)

  • Add HERE API v3 #343
  • Add Stadia Maps layers #344
  • Updated Hydda layers maxZoom to 20 #347
  • Add Jawg Maps layers #348
  • Updated Mapbox to new static tiles api #352
  • Removed OpenMapSurfer layers #354
  • Add MapTiler Cloud layers #355

1.9.1 (2019-12-06)

  • Add Cyclosm layer #335
  • Fix nlmaps.luchtfoto url #339
  • basemapAT: add terrain, surface layers #340

1.9.0 (2019-08-30)

  • Add TomTom layers #329
  • Add Stamen.TerrainLabels overlay #331
  • Add HERE traffic tiles to normal and hybrid #332

1.8.0 (2019-06-13)

  • Removed OSM B&W layer from example file
  • Removed bower.json file
  • Add support for Thunderforest Mobile Atlas and Neighbourhood map variants #325

1.7.0 (2019-05-14)

  • Additional OpenMapSurfer layers & updated url for tiles #322

1.6.0 (2019-03-28)

  • Tile attribution improvements #309
  • Updated openmapsurfer tiles url #310
  • Switched wmflbs.org tiles to https #311
  • Removed OpenStreetMap Black and white #319

1.5.0 (2018-11-06)

  • Prevented redirect in Stamen #299
  • Fixed default mapbox layer #303
  • Updated CartoDB -> CARTO #305
  • Removed OpenInfraMap #306
  • Updated HERE url & comments #307

1.4.0 (2018-08-25)

1.3.1 (2018-06-20)

  • No retina tiles for Stamen.Watercolor & TopOSMRelief #286

1.3.0 (2018-06-16)

  • Added GeoportailFrance provider 284
  • Removed mention to protocol relativity in README.md

1.2.0 (2018-06-05)

  • Make preview usable locally #256
  • Always use https when available #258
  • Added API Key for OpenWeatherMap #260
  • Fixed attribution of basemap.at #261
  • Added installation instructions #263
  • Added Wikimedia provider #266
  • Added OpenInfraMap/ OpenPtMap / OpenRailwayMap / OpenFireMap / SafeCast #266
  • Switched osm bzh to https #269
  • Added OpenStreetMap.CH bounding box + Wikimedia retina parameter and correct maxZoom #271
  • Fixed test for providers keys
  • Mention leaflet in usage example in README.md
  • Removed mention to force_http in README.md #273
  • Added information about Thunderforest key in README.md #277
  • Added retina support for MapBox #280
  • Added CartoDB.Voyager variants MapBox #281
  • Removed homegrown retina detection and added retina support for CartoDB & Stamen

1.1.17 (2017-06-29)

  • Added maxZoom for Hydda provider 242
  • Fixed maxZoom for all layers from the thunderforest provider
  • Added protocol relativity to the url for OpenStreetMap.DE variant.
  • Added OpenStreetMap.BZH #255
  • Added nlmaps provider #254

1.1.16 (2016-11-04)

1.1.15 (2016-08-09)

1.1.14 (2016-07-15)

  • Remove MapQuest, fixes #219
  • Accidentally skipped v1.1.12 and v1.1.13

1.1.11 (2016-06-04)

  • Added protocol relativity to OSM FR, OSM HOT and Hydda providers (#214, #215).

1.1.9 (2016-03-23)

  • Re-added HERE layers #209, discussion in #206.

1.1.8 (2016-03-22)

  • Removed HERE layers #206

1.1.7 (2015-12-16)

  • Removed Acetate tile layers #198

1.1.6 (2015-11-03)

  • Removed most of the NLS layers per NLS request #193, fixes #178
  • Added new variants to the HERE provider #183 by @andreaswc
  • Added some tests to make sure all the placeholders in the url template are replaced #188

1.1.5 (2015-10-01)

  • Improvements for the NLS layers #182 by @tomhughes
  • Check for valid bounds before fitting the preview map to undefined (fixes #185)
  • Add bounds for FreeMapSK (fixes #184)
  • Fix Stamen layers with .jpg extension (#187, fixes #184)

1.1.4 (2015-09-27)

  • Only include the interesting files in the npm package #180
  • Add GSGS_Ireland to NLS provider with tms:true to invert y-axis #181

1.1.3 (2015-09-26)

  • Add various historical layers of the Natioanal library of Scotland (NLS) #179
  • Add a page to visually check bounds #179

1.1.2 (2015-09-05)

  • Add CartoDB labels-only styles #170 by @almccon
  • Implement commonjs module #172
  • Added retina URL option #177, @routexl

1.1.1 (2015-06-22)

  • Update Mapbox API to v4 #167 by @gutenye
  • Started maintaining a changelog in CHANGELOG.md.