File: cloudmade.js

package info (click to toggle)
modestmaps-js 3.3.6%2Bds2-1
  • links: PTS, VCS
  • area: main
  • in suites: buster, stretch
  • size: 1,184 kB
  • ctags: 1,465
  • sloc: makefile: 58
file content (25 lines) | stat: -rw-r--r-- 753 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
// namespacing!
if (!MM) {
    var MM = { };
}

MM.CloudMadeProvider = function(key, style) {
    this.key = key;
    this.style = style;
    this.tileWidth = 256;
    this.tileHeight = 256;
};

MM.CloudMadeProvider.prototype = {
    key: null,
    style: null,
    getTile: function(coord) {
        coord = this.sourceCoordinate(coord);
        var worldSize = Math.pow(2, coord.zoom);
        var server = new Array('a.', 'b.', 'c.', '')[parseInt(worldSize * coord.row + coord.column, 10) % 4];
        var imgPath = new Array(this.key, this.style, this.tileWidth, coord.zoom, coord.column, coord.row).join('/');
        return 'http://' + server + 'tile.cloudmade.com/' + imgPath + '.png';
    }
};

MM.extend(MM.CloudMadeProvider, MM.MapProvider);