R
R
Rostislav2017-06-07 16:39:08
Yandex
Rostislav, 2017-06-07 16:39:08

How to display several labels from an array through Yandex Maps API?

This code should display 2 labels in Moscow. Why does it display 1 marker on the coast of Africa???

<script src="https://api-maps.yandex.ru/2.1/?lang=ru_RU" type="text/javascript"></script>

ymaps.ready(function(){
  if ($('div').is('#map')) {
    var i;
    var pl;
    var coords = ['55.765326, 37.627735','55.637366, 37.719745'];
    
    var myMap = new ymaps.Map("map", {
      center: [55.765326, 37.627735],
      zoom: 2,
      controls: ['zoomControl']
    });
    
    for (i = 0; i < coords.length; ++i) {
      pl = new ymaps.Placemark(coords[i]);
      myMap.geoObjects.add(pl);
      console.log(coords[i]);
    }

  };
});

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2017-06-07
@boarworm

Because the coordinates must be

var coords = ;
, maybe ;)

L
Leonid Smirnov, 2018-10-08
@SunyJun

Here is the answer to your question - https://www.pandoge.com/stati_i_sovety/kak-postavi...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question