Skip to content

Commit

Permalink
And a patch on that patch, to handle more than one map with the same …
Browse files Browse the repository at this point in the history
…provider per page

git-svn-id: https://modestmaps.googlecode.com/svn/trunk/js@828 a23cadb0-8de1-11de-82e5-a1837a67dc72
  • Loading branch information
tom.carden committed Oct 31, 2009
1 parent 9682b19 commit 5c1f037
Showing 1 changed file with 14 additions and 8 deletions.
22 changes: 14 additions & 8 deletions src/modestmaps.js
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ com.modestmaps.Coordinate.prototype = {
return "(" + this.row.toFixed(3) + ", " + this.column.toFixed(3) + " @" + this.zoom.toFixed(3) + ")";
},

toKey: function() {
toKey: function(optionalPrefix) {
var a = parseInt(this.row);
var b = parseInt(this.column);
var c = parseInt(this.zoom);
Expand All @@ -103,6 +103,12 @@ com.modestmaps.Coordinate.prototype = {
a=a-b; a=a-c; a=a^(c >>> 3);
b=b-c; b=b-a; b=b^(a << 10);
c=c-a; c=c-b; c=c^(b >>> 15);

if(optionalPrefix)
{
c = optionalPrefix + c;
}

return c;
},

Expand Down Expand Up @@ -851,7 +857,7 @@ com.modestmaps.Map.prototype = {

for (var y = baseCorner.y; y < this.dimensions.y; y += this.provider.tileHeight) {
for (var x = baseCorner.x; x < this.dimensions.x; x += this.provider.tileWidth) {
var tileKey = tileCoord.toKey();
var tileKey = tileCoord.toKey(this.idBase);
wantedTiles[tileKey] = true;
if (!this.tiles[tileKey]) {
if (!this.requestedTiles[tileKey]) {
Expand All @@ -860,17 +866,17 @@ com.modestmaps.Map.prototype = {
showParentLayer = true;
if (!onlyThisLayer) {
for (var pz = 1; pz <= 5; pz++) {
var parentKey = tileCoord.zoomBy(-pz).container().toKey();
var parentKey = tileCoord.zoomBy(-pz).container().toKey(this.idBase);
wantedTiles[parentKey] = true;
}
var childCoord = tileCoord.zoomBy(1);
wantedTiles[childCoord.toKey()] = true;
wantedTiles[childCoord.toKey(this.idBase)] = true;
childCoord.column += 1;
wantedTiles[childCoord.toKey()] = true;
wantedTiles[childCoord.toKey(this.idBase)] = true;
childCoord.row += 1;
wantedTiles[childCoord.toKey()] = true;
wantedTiles[childCoord.toKey(this.idBase)] = true;
childCoord.column -= 1;
wantedTiles[childCoord.toKey()] = true;
wantedTiles[childCoord.toKey(this.idBase)] = true;
}
}
else {
Expand Down Expand Up @@ -990,7 +996,7 @@ com.modestmaps.Map.prototype = {
},

requestTile: function(tileCoord) {
var tileKey = tileCoord.toKey();
var tileKey = tileCoord.toKey(this.idBase);
if (!this.requestedTiles[tileKey]) {
var tile = document.createElement('img'); // TODO: benchmark vs new Image() (in all browsers)
tile.id = tileKey;
Expand Down

0 comments on commit 5c1f037

Please sign in to comment.