fixed problem in google maps with wrapped maps

This commit is contained in:
javi 2013-09-30 13:30:58 +02:00
parent e642ae0e09
commit 9a0ac46ef3
2 changed files with 15 additions and 0 deletions

View File

@ -443,6 +443,14 @@ CanvasLayer.prototype.repositionCanvas_ = function() {
// overlayView's projection, not the map's // overlayView's projection, not the map's
var projection = this.getProjection(); var projection = this.getProjection();
var divTopLeft = projection.fromLatLngToDivPixel(this.topLeft_); var divTopLeft = projection.fromLatLngToDivPixel(this.topLeft_);
console.log(this.topLeft_.lng(), divTopLeft.x);
// when the zoom level is low, more than one map can be shown in the screen
// so the canvas should be attach to the map with more are in the screen
var mapSize = (1 << this.getMap().getZoom())*256;
if (Math.abs(divTopLeft.x) > mapSize) {
divTopLeft.x -= mapSize;
}
this.canvas.style[CanvasLayer.CSS_TRANSFORM_] = 'translate(' + this.canvas.style[CanvasLayer.CSS_TRANSFORM_] = 'translate(' +
Math.round(divTopLeft.x) + 'px,' + Math.round(divTopLeft.y) + 'px)'; Math.round(divTopLeft.x) + 'px,' + Math.round(divTopLeft.y) + 'px)';

View File

@ -105,6 +105,13 @@ GMapsTileLoader.prototype = {
}, },
getTilePos: function (tilePoint) { getTilePos: function (tilePoint) {
var limit = (1 << this._map.getZoom());
// wrap tile
tilePoint = {
x: ((tilePoint.x % limit) + limit) % limit,
y: tilePoint.y
};
tilePoint = new google.maps.Point( tilePoint = new google.maps.Point(
tilePoint.x * this.tileSize, tilePoint.x * this.tileSize,
tilePoint.y * this.tileSize tilePoint.y * this.tileSize