Y
Y
yumakaev2020-05-28 12:35:46
Yandex maps
yumakaev, 2020-05-28 12:35:46

How to generate points on a map from an array (Yandex maps)?

Good to everyone!

There is a map, there is an array, you need to scatter geopoints on the map, the coordinates of which are stored in an array, how to get them out of there?

Tried to do like this:

myMap.geoObjects.add(cityData.data.result.items.map((items, idx) => {
      new window.ymaps.Placemark([items.geo.l, items.geo.r], {
        hintContent: 'Контент',
        balloonContent: 'Это красивая метка'
      }, 
      {
        iconLayout: 'default#image',
        iconImageHref: 'logo',
        iconImageSize: [80, 80],
      })
    }))


Original (one point on the map):
const myPlacemark = new window.ymaps.Placemark([65.591182, 57.101262], {
        hintContent: 'Контент',
        balloonContent: 'Это красивая метка'
      }, 
      {
        iconLayout: 'default#image',
        iconImageHref: 'logo',
        iconImageSize: [80, 80],
      })

myMap.geoObjects.add(myPlacemark)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
freeExec, 2020-05-28
@freeExec

[items.geo.l, items.geo.r]

Items is an array, it doesn't have a property geo, it's not in vain that you are passed an index to the function idx, by which you need to access the array.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question