Skip to content
This repository was archived by the owner on Apr 6, 2021. It is now read-only.

Commit f216c94

Browse files
committed
Use multiple hosts to speed up tile loading.
1 parent b7849c1 commit f216c94

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

app/assets/javascripts/map/layers.coffee

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
Map.layers = Map.layers || {}
22

33
Map.layers.init = ->
4+
Map.layers.subdomainCount = 4
45
Map.layers.tilesets =
56
base:
67
attribution: ["Akshay Joshi", "Nikhil Mahajan"]
@@ -45,9 +46,11 @@ Map.layers.getTileHTML = (tile) ->
4546

4647
# Create and return the image object.
4748
img = $("<img class='map_tiles'></img>")
49+
sd = (tile.z + real_x + real_y) % Map.layers.subdomainCount
50+
host = "http://" + sd + ".zeus.akshayjoshi.com"
4851
tile_path = tile.type + "/" + tile.z + "/" + real_x + "/" + real_y + ".png"
4952
img.attr "id", tile.id
50-
img.attr "src", "http://zeus.akshayjoshi.com/tiles/" + tile_path
53+
img.attr "src", host + "/tiles/" + tile_path
5154
img.offset {top: tile.y * Map.tileSize, left: tile.x * Map.tileSize}
5255
img.bind "load", ->
5356
$(this).addClass "map_tiles_loaded"

0 commit comments

Comments
 (0)