Thanks Andy.
One problem is that in priniple the marker needs to go beyond the
physical map, or at least give the appearance of doing so, which is
achieved inherently by my existing method. I've managed to correct
for the latitude as follows:
var loc2 = new google.maps.LatLng( loc1.lat() + markerLength*Math.sin
(rAzim), loc1.lng() + markerLength*Math.cos(rAzim)/Math.cos(loc1.lat()
*RAD) );
For short marker lengths, this tends to the correct azimuth, but even
increasing the marker length from 0.005 to 0.05 degrees (approx 556m
to 5.56km) leads to a noticable shift in the marker of a pixel or two
when you flick between the versions.
I haven't had time to look at your suggestion yet, but will do so.
On May 31, 4:27 pm, Andy Anderson <[email protected]> wrote:
> You need to be working in map/pixel coordinates (x, y), not geographic
> coordinates (lat, lng). The projection from the latter to the former
> is Mercator, modulo some linear tweaks of the y coordinate axis (see
> <http://en.wikipedia.org/wiki/Mercator_projection>). In Mercator,
> coordinate changes ?x and ?y are designed to be the same over short
> distances, and therefore so will be the azimuth ~ arctangent (?x/?y).
>
> I haven't tried this, but I think you can do the following: convert
> your (lat, lng) to pixels with
>
> p:GPoint = map.fromLatLngToContainerPixel(GLatLng(lat, lng))
>
> Then with your chosen displacement in pixels, calculate your new x and
> y with
>
> x = p.x + disp * Math.sin(azimuth)
> y = p.y - disp * Math.cos(azimuth)
>
> and then calculate the new marker position with
>
> marker:GLatLng = map.fromContainerPixelToLatLng(GPoint(x, y))
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Google Maps API" 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-API?hl=en
-~----------~----~----~----~------~----~------~--~---