Simple question: Getting just latitude or just longitude from latLng

2,982 views
Skip to first unread message

Aaron

unread,
Feb 16, 2011, 4:37:43 PM2/16/11
to google-map...@googlegroups.com
Hi there,

I've got a little function that sends latLng data to a textbox. It is currently in the format: (51.519934101320175, -0.11481629101562918)


What I would like is to split out the latitude and longitude so that one text box gets latitude and the other gets longitude but I don't know how to retrieve just the latitude data from latLng.

I've had a look at:

I've also tried variations of latLng.latitude and so on but no luck. Any ideas would be appreciated.

A

geoco...@gmail.com

unread,
Feb 16, 2011, 4:40:54 PM2/16/11
to Google Maps JavaScript API v3
On Feb 16, 1:37 pm, Aaron <aaron.jerl...@gmail.com> wrote:
> Hi there,
>
> I've got a little function that sends latLng data to a textbox. It is
> currently in the format: (51.519934101320175, -0.11481629101562918)
>
> What I would like is to split out the latitude and longitude so that one
> text box gets latitude and the other gets longitude but I don't know how to
> retrieve just the latitude data from latLng.
>
> I've had a look at:http://code.google.com/apis/maps/documentation/javascript/reference.h...

And has these documented methods:
lat() number Returns the latitude in degrees.
lng() number Returns the longitude in degrees.

Did you try them?

-- Larry

Rossko

unread,
Feb 16, 2011, 4:42:21 PM2/16/11
to Google Maps JavaScript API v3
> I've also tried variations of latLng.latitude and so on but no luck. Any
> ideas would be appreciated.

Try the documentation again. It suggests xxx.lat() where xxx is
whatever variable holds your latLng object.

Aaron

unread,
Feb 16, 2011, 5:08:04 PM2/16/11
to google-map...@googlegroups.com
Hi,

thank you for your responses. I did try lat and lng() but called them incorrectly. 

Thanks again for the tips :)

A

Diogo Outerelo da Silva

unread,
Feb 16, 2011, 5:49:12 PM2/16/11
to google-map...@googlegroups.com
You variable is a instance of latlng? i think that you don't have this instance. Also look if the object was created... 
I suggest to use a tool like firebug to check...


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



--
Atc,
Diogo

--
Reply all
Reply to author
Forward
0 new messages