Search code examples
javascriptgoogle-mapssedgpscoordinate

Javascript replace coordinate [1.111111,2.22222]


I had been searching for so long without success...

I would like in JavaScript make my [1.111111,2.222222] coordinates into:

  • lat = 1.111111
  • lng = 2.222222

Like this I will be able to treat them. Sorry for this newbie question, hope will help future beginners as me :)

Thanks !


Solution

  • Are you asking to take an array of numbers into their separate variables?

    For instance:

    var array = [1.111111 , 2.222222];
    var lat = array[0]; //lat is now equal to 1.111111
    var lng = array[1]; //lng is now equal to 2.222222`
    

    If not, can you please give a little more detail?