M
M
mletov2015-09-09 15:12:01
JavaScript
mletov, 2015-09-09 15:12:01

How to pass latitude and longitude correctly when using Yandex.Map API?

Please tell me: there is such a piece of code, it draws a label on the map, everything is according to the manual.

var latitude = 59.963314;
                var longitude = 30.267754;
                var placemark = new ymaps.Placemark([latitude, longitude]);
                myMap.geoObjects.add(placemark);

And there is my piece of code. The same values ​​are read from json.
....
                 var latitude = parseFloat(obj[0].latitude.trim());                 
                 var longitude = parseFloat(obj[0].longitude.trim());              
                 console.log(latitude);
                 console.log(longitude);
                 var placemark = new ymaps.Placemark(latitude, longitude);
                 myMap.geoObjects.add(placemark);

I get the error "Uncaught TypeError: t is not a function". The values ​​of the variables in the console are the same (59.963314, 30.267754). I suspect that everything depends on typing, but I don’t understand how and what to lead to correctly. I already tried to transfer float as a string.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
forgotten, 2015-09-09
@mletov

In manual
A you
find two differences;)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question