0

Having problems getting lat & lng from googles response.

Google is responding some xml looking like :

 "location" : { "lat" : 53.55914120, "lng" : 10.00923520 }, 

I´m parsing this with var r = results[0].geometry.location;

and alerting (r) says:

(53.55914120,10.00923520) 

now the problem :

When i try var r = results[0].geometry.location.lat;

and alerting (r) says:

function (){return this[a]} 

so my question is:

when r = results[0].geometry.location; r = (53.55914120,10.00923520)

how do i get lat and lng from it ?

alert(r[0]r[1]) <!-- doesn´t work, returns "undefined" --> 

or

how can i store lat & lng in two different variables from the beginning,

Thanks in advance i expected var r = results[0].geometry.location.lat; but that doesn´t work

2
  • What do r[0] and r[1] give you? Commented Feb 20, 2013 at 11:36
  • ah didn´t mention, sry --- returns "undefined" Commented Feb 20, 2013 at 11:37

1 Answer 1

1

Try this

var latitude = results[0].geometry.location.lat(); var longitude = results[0].geometry.location.lng(); 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.