Permalink
Browse files

made semi-working example for static tiles

  • Loading branch information...
1 parent f40c607 commit 521dc1895a9d577b888bb740c265d5f9a4bc10db @jrasky jrasky committed Apr 11, 2012
Showing with 38 additions and 33,218 deletions.
  1. +38 −6 geocamLayer/static/geocamLayer/static_tiles.js
  2. +0 −874 geocamLayer/static/geocamLayer/tiles/0/0/0
  3. +0 −874 geocamLayer/static/geocamLayer/tiles/0/1/0
  4. +0 −874 geocamLayer/static/geocamLayer/tiles/1/1/0
  5. +0 −874 geocamLayer/static/geocamLayer/tiles/1/1/1
  6. +0 −874 geocamLayer/static/geocamLayer/tiles/1/2/0
  7. +0 −874 geocamLayer/static/geocamLayer/tiles/1/2/1
  8. +0 −874 geocamLayer/static/geocamLayer/tiles/2/3/1
  9. +0 −874 geocamLayer/static/geocamLayer/tiles/2/3/2
  10. +0 −874 geocamLayer/static/geocamLayer/tiles/2/4/1
  11. +0 −874 geocamLayer/static/geocamLayer/tiles/2/4/2
  12. +0 −874 geocamLayer/static/geocamLayer/tiles/3/7/3
  13. +0 −874 geocamLayer/static/geocamLayer/tiles/3/7/4
  14. +0 −874 geocamLayer/static/geocamLayer/tiles/3/8/3
  15. +0 −874 geocamLayer/static/geocamLayer/tiles/3/8/4
  16. +0 −874 geocamLayer/static/geocamLayer/tiles/4/15/7
  17. +0 −874 geocamLayer/static/geocamLayer/tiles/4/15/8
  18. +0 −874 geocamLayer/static/geocamLayer/tiles/4/16/7
  19. +0 −874 geocamLayer/static/geocamLayer/tiles/4/16/8
  20. +0 −874 geocamLayer/static/geocamLayer/tiles/5/31/15
  21. +0 −874 geocamLayer/static/geocamLayer/tiles/5/31/16
  22. +0 −874 geocamLayer/static/geocamLayer/tiles/5/32/15
  23. +0 −874 geocamLayer/static/geocamLayer/tiles/5/32/16
  24. +0 −874 geocamLayer/static/geocamLayer/tiles/6/63/31
  25. +0 −874 geocamLayer/static/geocamLayer/tiles/6/63/32
  26. +0 −874 geocamLayer/static/geocamLayer/tiles/6/64/31
  27. +0 −874 geocamLayer/static/geocamLayer/tiles/6/64/32
  28. +0 −874 geocamLayer/static/geocamLayer/tiles/7/127/63
  29. +0 −874 geocamLayer/static/geocamLayer/tiles/7/127/64
  30. +0 −874 geocamLayer/static/geocamLayer/tiles/7/128/63
  31. +0 −874 geocamLayer/static/geocamLayer/tiles/7/128/64
  32. +0 −874 geocamLayer/static/geocamLayer/tiles/8/255/127
  33. +0 −874 geocamLayer/static/geocamLayer/tiles/8/255/128
  34. +0 −874 geocamLayer/static/geocamLayer/tiles/8/256/127
  35. +0 −874 geocamLayer/static/geocamLayer/tiles/8/256/128
  36. +0 −874 geocamLayer/static/geocamLayer/tiles/9/511/255
  37. +0 −874 geocamLayer/static/geocamLayer/tiles/9/511/256
  38. +0 −874 geocamLayer/static/geocamLayer/tiles/9/512/255
  39. +0 −874 geocamLayer/static/geocamLayer/tiles/9/512/256
@@ -1,6 +1,7 @@
function initialize() {
window.map = new google.maps.Map(document.getElementById("map_canvas"), {zoom: 6, mapTypeId: google.maps.MapTypeId.ROADMAP});
- //google.maps.event.addListener(map,'bounds_changed',getClusters);
+ google.maps.event.addListener(map,'bounds_changed',boundsChanged);
+ //google.maps.event.addListener(map,'bounds_changed',clearPoints);
window.points = new Array();
window.bboxes = new Object();
window.conn = null;
@@ -44,7 +45,38 @@ function initialize() {
}
// load a tile to test stuff out
- loadTile(0,0,0);
+ //loadTile(0,0,0);
+ //loadTile(0,0,1);
+
+ //loadTile(0,1,0);
+ //loadTile(0,1,1);
+ //clearPoints();
+}
+
+function boundsChanged() {
+ bounds = map.getBounds();
+ south = bounds.getSouthWest().lat();
+ west = bounds.getSouthWest().lng();
+ north = bounds.getNorthEast().lat();
+ east = bounds.getNorthEast().lng();
+ size = Math.max(south-north, east-west);
+
+ zoom = Math.ceil(Math.log(360/size)/Math.log(2));
+ if (isNaN(zoom)) zoom = 1;
+ tile_size = 360/Math.pow(2,zoom)
+
+ west_x = Math.floor((west-(-180))/tile_size)
+ south_y = Math.floor((south-(-90))/tile_size)
+ east_x = Math.ceil((east-(-180))/tile_size)
+ north_y = Math.ceil((east-(-180))/tile_size)
+
+ clearPoints();
+
+ for (x=west_x; x < east_x; x++) {
+ for (y=south_y; y < north_y; y++) {
+ loadTile(zoom,x,y);
+ }
+ }
}
function loadTile(zoom,x,y) {
@@ -55,9 +87,12 @@ function loadTile(zoom,x,y) {
}
function clearPoints() {
+ console.log("clearing points");
for (x=0;x<points.length;x++) {
points[x].setVisible(false);
}
+ points = new Array();
+ bboxes = new Object();
}
function processTile() {
@@ -73,11 +108,8 @@ function processTile() {
return;
}
parsed = JSON.parse(conn.responseText);
- clearPoints();
- console.log(parsed);
for (x in parsed['features']) {
cluster = parsed['features'][x];
- console.log(cluster);
pos = cluster['geometry']['coordinates'].toString().split(',');
marker = new google.maps.Marker({position:new google.maps.LatLng(pos[0], pos[1]), map:map, clickable:true, icon:new google.maps.MarkerImage(url='/static/arrow.png')});
bboxes[new google.maps.LatLng(pos[0], pos[1])] = cluster['properties']['bbox'];
@@ -89,6 +121,6 @@ function processTile() {
map.fitBounds(bounds);
}
);
- points[cluster.length] = marker;
+ points[points.length] = marker;
}
}
Oops, something went wrong.

0 comments on commit 521dc18

Please sign in to comment.