I'm trying to fit the x & y coords I get from a game to a custom image map with Google Maps V3.
The coords I get from the game are both between 0 and 15360. In the custom map the NorthEast corner LatLng
is (95, 180) and the SouthWest corner LatLng
is (-82.5, -180).
So, my function to transform from game coords to Google Map LatLng
is:
function getLatLngFromCoords(x, y) {
x = parseFloat(x.replace(",", "."));
y = parseFloat(y.replace(",", "."));
var lng = x / (15360 / 360) - 180;
var lat = y / (15360 / 177.5) - 95;
return new google.maps.LatLng(lat, lng);
}
but it doesn't fit right to the positions.
I got the NorthEast and SouthWest LatLng
making Markers and adjusting them to see when they was in the corner of my image map.
Wherever, when I get the bounds of the map with map.getBounds()
I see this:
map.getBounds().getNorthEast(); // nb: 89.76247963221984, ob: 180
map.getBounds().getSouthWest(); // nb: -87.43214656352167, ob: -180
You are using wrong latitude value for NorthEast corner. Your values are
LatLng
(95, 180). Maximum value for latitude is 90, so this is most probably cutoff to (90, 180).For example, using
I got object: