A
A
Alexander Ivanov2018-03-27 15:27:41
JavaScript
Alexander Ivanov, 2018-03-27 15:27:41

How to convert string to yandex map object of coordinates?

[55.7977,37.7283] - for example this term in the object.
From the back, I get strings, so I try to convert them for the loop

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2018-03-27
@cimonlebedev

[55.7977,37.7283] - for example, this deadline in the object

Probably, after all, into an array - the coordinates in ymaps are specified as an array of numbers.
JSON.parse(str)
or or or
str.match(/[0-9]+(\.[0-9]+)?/g).map(n => +n)
str.slice(1, -1).split(',').map(Number)
eval(str)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question