dper / staticmapmaker

A PNG map maker for OpenStreetMap and similar tile servers.
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

Add new Stamen layers #9

Closed dper closed 10 years ago

dper commented 10 years ago

When messing around with OpenLayers, I found information on two layers that could be used here. The following is JavaScript code with all the relevant information in it.

/**
 * Class: OpenLayers.Layer.OSM.Stamen
 *
 * Inherits from:
 *  - <OpenLayers.Layer.OSM>
 */
OpenLayers.Layer.OSM.Stamen = OpenLayers.Class(OpenLayers.Layer.OSM, {
    /**
     * Constructor: OpenLayers.Layer.OSM.Stamen
     *
     * Parameters:
     * name - {String}
     * options - {Object} Hashtable of extra options to tag onto the layer
     */
    initialize: function(name, options) {
        var url = [
            "http://c.tile.stamen.com/watercolor/${z}/${x}/${y}.jpg",
        ];
        options = OpenLayers.Util.extend({
            numZoomLevels: 19,
            attribution: "&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors, Tiles courtesy of <a href='http://maps.stamen.com'>Stamen Design</a>",
            buffer: 0,
            transitionEffect: "resize"
        }, options);
        var newArguments = [name, url, options];
        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
    },

    CLASS_NAME: "OpenLayers.Layer.OSM.Stamen"
});

/**
 * Class: OpenLayers.Layer.OSM.StamenBW
 *
 * Inherits from:
 *  - <OpenLayers.Layer.OSM>
 */
OpenLayers.Layer.OSM.StamenBW = OpenLayers.Class(OpenLayers.Layer.OSM, {
    /**
     * Constructor: OpenLayers.Layer.OSM.StamenBW
     *
     * Parameters:
     * name - {String}
     * options - {Object} Hashtable of extra options to tag onto the layer
     */
    initialize: function(name, options) {
        var url = [
            "http://a.tile.stamen.com/toner/${z}/${x}/${y}.jpg",
        ];
        options = OpenLayers.Util.extend({
            numZoomLevels: 19,
            attribution: "&copy; <a href='http://www.openstreetmap.org/copyright'>OpenStreetMap</a> contributors, Tiles courtesy of <a href='http://maps.stamen.com'>Stamen Design</a>",
            buffer: 0,
            transitionEffect: "resize"
        }, options);
        var newArguments = [name, url, options];
        OpenLayers.Layer.OSM.prototype.initialize.apply(this, newArguments);
    },

    CLASS_NAME: "OpenLayers.Layer.OSM.StamenBW"
});
dper commented 10 years ago

Added. Done.