I'm not absolutely sure if I've understood your problem, so here's what I 
think you want to do:

You have an marker-icon that is shifted some pixels (!) away from the actual 
location you want to point at. When the user clicks on the marker, a line 
from your anchor to the actual location shall be drawn. Is this correct?

If this would be the case, I have implemented the following method:

/*
 * Calculates the Latitude/Longitude per 
 * Pixel ratio based on the given zoom.
 * 
 * If you want to speed up things, you might
 * replace the formula by an array of constant
 * LatLng values, as the ratio isn't depending
 * on any factors but the map's scaling. If
 * This should change in the future, you would have
 * to adjust the formula either way.
 *
 * @param zoom The zoom value for which you want
 *          to know the conversion ratio from
 *          pixel to LatLng
 */
function getLatLngPerPixel(zoom) {
        var lng = 360 / (256 * (Math.pow(2,zoom))); //256 is the Map Width (px) 
on zoom = 0
        var lat = 2 * lng / Math.PI;
        
        return new google.maps.LatLng(lat, lng);
}

This method gives you the "size" of a pixel in Latitude/Longitude 
coordinates for a specific map zoom (by the way, you could also fill this 
method with a static array containing the precalculated values for each 
zoom). Now if you want to draw a line from your location to the anchor, just 
get the conversion ratio, take your location as point A of the line, then 
calculate point B of the line by multiplying your x/y values with the 
corresponding conversion ratio and adding this to the coordinates of your 
point A.

-- 
You received this message because you are subscribed to the Google Groups 
"Google Maps JavaScript API v3" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to