Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@mcechini
Forked from mourner/TileLayer.Common.js
Last active January 24, 2017 21:51
Show Gist options
  • Star 10 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save mcechini/a814f36c7d1612e84c18 to your computer and use it in GitHub Desktop.
Save mcechini/a814f36c7d1612e84c18 to your computer and use it in GitHub Desktop.
var cloudmade = new L.TileLayer.CloudMade({key: 'API-KEY', styleId: 997}),
openStreetMap = new L.TileLayer.OpenStreetMap(),
openCycleMap = new L.TileLayer.OpenCycleMap(),
mapquestOsm = new L.TileLayer.MapQuestOpen.OSM(),
mapquestAerial = new L.TileLayer.MapQuestOpen.Aerial(),
mapbox = new L.TileLayer.MapBox({user: 'kkaefer', map: 'island'});
nasagibs = new L.TileLayer.NasaGibs({layer: 'MODIS_Terra_CorrectedReflectance_TrueColor', tilematrixset: 'GoogleMapsCompatible_Level9'});
// Lefalet shortcuts for common tile providers - is it worth adding such 1.5kb to Leaflet core?
L.TileLayer.Common = L.TileLayer.extend({
initialize: function (options) {
L.TileLayer.prototype.initialize.call(this, this.url, options);
}
});
(function () {
var osmAttr = '&copy; <a href="http://openstreetmap.org">OpenStreetMap</a> contributors, <a href="http://creativecommons.org/licenses/by-sa/2.0/">CC-BY-SA</a>';
L.TileLayer.CloudMade = L.TileLayer.Common.extend({
url: 'http://{s}.tile.cloudmade.com/{key}/{styleId}/256/{z}/{x}/{y}.png',
options: {
attribution: 'Map data ' + osmAttr + ', Imagery &copy; <a href="http://cloudmade.com">CloudMade</a>',
styleId: 997
}
});
L.TileLayer.OpenStreetMap = L.TileLayer.Common.extend({
url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
options: {attribution: osmAttr}
});
L.TileLayer.OpenCycleMap = L.TileLayer.Common.extend({
url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
options: {
attribution: '&copy; OpenCycleMap, ' + 'Map data ' + osm
}
});
var mqTilesAttr = 'Tiles &copy; <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png" />';
L.TileLayer.MapQuestOpen.OSM = L.TileLayer.Common.extend({
url: 'http://otile{s}.mqcdn.com/tiles/1.0.0/{type}/{z}/{x}/{y}.png',
options: {
subdomains: '1234',
type: 'osm',
attribution: 'Map data ' + L.TileLayer.OSM_ATTR + ', ' + mqTilesAttr
}
});
L.TileLayer.MapQuestOpen.Aerial = L.TileLayer.MapQuestOpen.OSM.extend({
options: {
type: 'sat',
attribution: 'Imagery &copy; NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency, ' + mqTilesAttr
}
});
L.TileLayer.MapBox = L.TileLayer.Common.extend({
url: 'http://{s}.tiles.mapbox.com/v3/{user}.{map}/{z}/{x}/{y}.png'
});
L.TileLayer.NasaGibs = L.TileLayer.Common.extend({
url: 'http://map1.vis.earthdata.nasa.gov/wmts-webmerc/{layer}/default//{tilematrixset}/{z}/{y}/{x}.{format}',
options: {
attribution: 'Imagery provided by services from the Global Imagery Browse Services (GIBS), operated by the NASA/GSFC/Earth Science Data and Information System (ESDIS, https://earthdata.nasa.gov) with funding provided by NASA/HQ.'
}
});
}());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment