Skip to content

Instantly share code, notes, and snippets.

@davidkeen
Forked from mourner/TileLayer.Common.js
Created September 15, 2012 21:17
Show Gist options
  • Save davidkeen/3729820 to your computer and use it in GitHub Desktop.
Save davidkeen/3729820 to your computer and use it in GitHub Desktop.

Revisions

  1. @mourner mourner revised this gist Feb 11, 2012. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion example.js
    Original file line number Diff line number Diff line change
    @@ -2,4 +2,5 @@ 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();
    mapquestAerial = new L.TileLayer.MapQuestOpen.Aerial(),
    mapbox = new L.TileLayer.MapBox({user: 'kkaefer', map: 'island'});
  2. @mourner mourner revised this gist Feb 11, 2012. 1 changed file with 49 additions and 43 deletions.
    92 changes: 49 additions & 43 deletions TileLayer.Common.js
    Original file line number Diff line number Diff line change
    @@ -6,46 +6,52 @@ L.TileLayer.Common = L.TileLayer.extend({
    }
    });

    L.TileLayer.OSM_ATTR = '&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 ' + L.TileLayer.OSM_ATTR + ', 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: L.TileLayer.OSM_ATTR
    }
    });

    L.TileLayer.OpenCycleMap = L.TileLayer.Common.extend({
    url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
    options: {
    attribution: '&copy; OpenCycleMap, ' + 'Map data ' + L.TileLayer.OSM_ATTR
    }
    });

    L.TileLayer.MapQuestOpen = {
    ATTR: 'Imagery &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 + ', ' + L.TileLayer.MapQuestOpen.ATTR
    }
    });

    L.TileLayer.MapQuestOpen.Aerial = L.TileLayer.MapQuestOpen.OSM.extend({
    options: {
    type: 'sat',
    attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency, ' + L.TileLayer.MapQuestOpen.ATTR
    }
    });
    (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'
    });

    }());
  3. @mourner mourner revised this gist Feb 11, 2012. 1 changed file with 1 addition and 5 deletions.
    6 changes: 1 addition & 5 deletions TileLayer.Common.js
    Original file line number Diff line number Diff line change
    @@ -6,10 +6,8 @@ L.TileLayer.Common = L.TileLayer.extend({
    }
    });


    L.TileLayer.OSM_ATTR = '&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: {
    @@ -18,7 +16,6 @@ L.TileLayer.CloudMade = L.TileLayer.Common.extend({
    }
    });


    L.TileLayer.OpenStreetMap = L.TileLayer.Common.extend({
    url: 'http://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png',
    options: {
    @@ -33,7 +30,6 @@ L.TileLayer.OpenCycleMap = L.TileLayer.Common.extend({
    }
    });


    L.TileLayer.MapQuestOpen = {
    ATTR: 'Imagery &copy; <a href="http://www.mapquest.com/" target="_blank">MapQuest</a> <img src="http://developer.mapquest.com/content/osm/mq_logo.png" />'
    };
    @@ -52,4 +48,4 @@ L.TileLayer.MapQuestOpen.Aerial = L.TileLayer.MapQuestOpen.OSM.extend({
    type: 'sat',
    attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency, ' + L.TileLayer.MapQuestOpen.ATTR
    }
    });
    });
  4. @mourner mourner revised this gist Feb 11, 2012. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions example.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,5 @@
    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();
  5. @mourner mourner created this gist Feb 11, 2012.
    55 changes: 55 additions & 0 deletions TileLayer.Common.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,55 @@
    // 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);
    }
    });


    L.TileLayer.OSM_ATTR = '&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 ' + L.TileLayer.OSM_ATTR + ', 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: L.TileLayer.OSM_ATTR
    }
    });

    L.TileLayer.OpenCycleMap = L.TileLayer.Common.extend({
    url: 'http://{s}.tile.opencyclemap.org/cycle/{z}/{x}/{y}.png',
    options: {
    attribution: '&copy; OpenCycleMap, ' + 'Map data ' + L.TileLayer.OSM_ATTR
    }
    });


    L.TileLayer.MapQuestOpen = {
    ATTR: 'Imagery &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 + ', ' + L.TileLayer.MapQuestOpen.ATTR
    }
    });

    L.TileLayer.MapQuestOpen.Aerial = L.TileLayer.MapQuestOpen.OSM.extend({
    options: {
    type: 'sat',
    attribution: 'Portions Courtesy NASA/JPL-Caltech and U.S. Depart. of Agriculture, Farm Service Agency, ' + L.TileLayer.MapQuestOpen.ATTR
    }
    });