I *think* i have made a tiny bit of progress but I'm still stuck. It
seems that in a mercator projection the longtitude (x axis) scales
normally. So because I am trying to get a % pixel position on the map,
I can simply say "(percentage position * 360) - 180" to get the
longtitude.

HOWEVER, latitude (y-axis) does not scale so simply, gridlines have a
scaling factor of 1 at 0 degrees but spread out towards infinity at
the poles. What I need is a bit of maths that I can use to convert a %
or pixel position into a latitude. I have a suspiscion what I need
might be called a reverse gudermannian function but it is at this
point my knowledge and understanding of maths is clutching at straws.

Does anyone have such a function that I can copy paste into my code to
convert a % latitute position on a square map into a trye latitude
value?

On May 5, 10:54 pm, Kesuke <nick_dai...@hotmail.com> wrote:
> Hate to bump, but someone must have done this as it's been asked here
> a lot before (just with no clear answer). I'm sure one of us has the
> maths for this ready to go.
>
> On May 2, 4:48 pm, Kesuke <nick_dai...@hotmail.com> wrote:
>
>
>
> > How do I convert a pixel position to a latlng. I've searched and
> > searched but its suprisingly hard to get a clear answer.
>
> > For example, at zoom level 2 lets say I want to get the latlng of a
> > position that is 40% along the x axis and 60% along the y-axis.
>
> > So;
>
> > 2^zoomlevel * 256 = 1024 pixel map.
> > x co-ordinate = 1024 * 0.4 = 410
> > y co-ordinate = 1024 * 0.6 = 614
>
> > How can i now convert those pixel co-ordinates (410,614) into a
> > corresponding latlng?
>
> > I am using the bog-standard mercator projection.- Hide quoted text -
>
> - Show quoted text -

-- 
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 google-maps-js-api-v3@googlegroups.com.
To unsubscribe from this group, send email to 
google-maps-js-api-v3+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/google-maps-js-api-v3?hl=en.

Reply via email to