A
A
Alibek Kulseitov2018-12-02 15:12:29
JavaScript
Alibek Kulseitov, 2018-12-02 15:12:29

Several points of Yandex maps?

The task is that there should be a Yandex map with an unlimited number of points, and when clicked, a description with the address should appear as well as a custom label. I implemented all this for one point using this article Link 1 I

customized the label, the description was displayed on click. Now the problem is when I try to add many points, the custom label only works for the one I made, but the description does not come out for others. This is what I tried to integrate using this article Link 2

My code for one label looks like this now:

ymaps.ready(init);
    var myMap;

    function init() {

        myMap = new ymaps.Map("YMapsID", {
            center: [43.238253, 76.945465], // Координаты объекта
            zoom: 13, // Маштаб карты
            controls: [] // Отключаем элементы управления.
        });

        // Добавим на карту ползунок масштаба и линейку.
        myMap.controls.add(
            new ymaps.control.ZoomControl()
        );

        // Отключаем zoom на скролле мыши
        myMap.behaviors.disable('scrollZoom');

        myPlacemark = new ymaps.Placemark([43.238253, 76.945465], { // Координаты метки объекта
            balloonContent: "<div class='ya-map'><div class='ya-map__city'>Алматы</div><div class='ya-map__title'>Название филиала</div><p>Богенбай батыра, 172 2 этаж, офис 72 вход с Желтоксан</p><p>+7 777 727 35 63<br>+7 777 727 35 63<br>+7 777 727 35 63</p></div>" // Надпись метки
        }, {
            iconLayout: 'default#image',

            // Своё изображение иконки метки
            iconImageHref: "%=static=%img/general/ic-map-marker.svg",

            // Размер мкетки
            iconImageSize: [40, 50],

            // Смещение левого верхнего угла иконки относительно
            // её "ножки" (точки привязки).
            iconImageOffset: [-20, -25]
        });

        myMap.geoObjects.add(myPlacemark);
        //myPlacemark.balloon.open();

    };


How to integrate the code from the second article here so that all tags are customized + each description comes out.
For further transmission to the back end.

Here's a demo with a few tags

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Anton Shamanov, 2018-12-03
@AlibekKulseitov

ymaps.ready(function () {
    var map = new ymaps.Map(
        'map-pickups', 
        {center: [55.75, 37.64], zoom: 10, controls: ['zoomControl', 'fullscreenControl']}, 
        {searchControlProvider: 'yandex#search'}
    );
    var objManager = new ymaps.ObjectManager({
        clusterize: true,
        gridSize: 32,
        clusterDisableClickZoom: true
    });
    objManager.objects.options.set('preset', 'islands#blueDotIcon');
    objManager.clusters.options.set('preset', 'islands#blueClusterIcons');
    map.geoObjects.add(objManager);
    
    var pickups = {
        type: 'FeatureCollection',
        features: []
    };
    var coordinates = [
        [55.831903, 37.411961],
        [55.763338, 37.565466],
        [55.763338, 37.565466],
        [55.744522, 37.616378],
        [55.780898, 37.642889],
        [55.793559, 37.435983],
        [55.800584, 37.675638],
        [55.716733, 37.589988],
        [55.691046, 37.711026],
        [55.723123, 37.406067],
        [55.843363, 37.778445]
    ];
    $.each(coordinates, function (id, coordinates) {
        pickups.features.push({
            type: 'Feature', 
            id: id, 
            geometry: {type: 'Point', coordinates: coordinates}, 
            properties: {
                balloonContentHeader: 'ПВЗ Grastin №' + id, 
                balloonContentBody: 'Адрес доставки, описание, контакты, время работы.', 
                balloonContentFooter: 'График работы: пн-сб 10:00-20:00', 
                clusterCaption: 'ПВЗ Grastin №' + id, 
                hintContent: 'ПВЗ Grastin №' + id
            }
        });
    });
    objManager.add(pickups);
    map.setBounds(map.geoObjects.getBounds());
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question