From 874bf9da8d612b9efd7f5d5065440ee3fc77aeda Mon Sep 17 00:00:00 2001 From: Mike Primm Date: Sat, 9 Jul 2011 18:04:42 -0500 Subject: [PATCH] Fix marker/player world-to-map coordinate transform in hdmap.js --- web/js/hdmap.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/web/js/hdmap.js b/web/js/hdmap.js index 2640daa9..9e2cf632 100644 --- a/web/js/hdmap.js +++ b/web/js/hdmap.js @@ -1,6 +1,7 @@ function HDProjection() {} HDProjection.prototype = { extrazoom: 0, + worldtomap: null, fromLatLngToPoint: function(latLng) { return new google.maps.Point(latLng.lng()*config.tileWidth, latLng.lat()*config.tileHeight); }, @@ -8,7 +9,11 @@ HDProjection.prototype = { return new google.maps.LatLng( point.y/config.tileHeight, point.x/config.tileWidth); }, fromWorldToLatLng: function(x, y, z) { - return new google.maps.LatLng(-z / config.tileWidth / (1 << this.extrazoom), x / config.tileHeight / (1 << this.extrazoom)); + var wtp = this.worldtomap; + var xx = x*wtp[0] + y*wtp[1] + z*wtp[2]; + var yy = x*wtp[3] + y*wtp[4] + z*wtp[5]; + + return new google.maps.LatLng(-yy / config.tileHeight / (1 << this.extrazoom), xx / config.tileWidth / (1 << this.extrazoom)); } }; @@ -69,6 +74,7 @@ HDMapType.prototype = $.extend(new DynMapType(), { var size; var extrazoom = this.mapzoomout; this.projection.extrazoom = extrazoom; + this.projection.worldtomap = this.worldtomap; this.maxZoom = 2 + extrazoom; if (zoom <= extrazoom) { size = 128;