I guess you want to obtain the coordinates of the pixel of the
viewport under the pointer.
The problem is that method fromLatLngToPoint returns the point in
"world coordinates".
To obtain the pixel you need to translate the point with respect to
the origin of the viewport (the upper left corner), and then scale
with respect to the zoom level of the map. Try this:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://
www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/
html;charset=ISO-8859-1">
var point = convertPoint(mEvent.latLng);
var elem = document.getElementById('latlng-control');
elem.innerHTML = point.x+"<br>"+point.y;
});
}
function convertPoint(latLng) {
var
topRight=map.getProjection().fromLatLngToPoint(map.getBounds().getNorthEast());
var
bottomLeft=map.getProjection().fromLatLngToPoint(map.getBounds().getSouthWest());
var scale=Math.pow(2,map.getZoom());
var worldPoint=map.getProjection().fromLatLngToPoint(latLng);
return new google.maps.Point((worldPoint.x-
bottomLeft.x)*scale,(worldPoint.y-topRight.y)*scale);
}
google.maps.event.addDomListener(window, 'load', init);
</script>
</head>
<body>
<div id="map">
</div>
<div id="latlng-control">
</div>
</body>
</html>
Ciao.