A
A
Anton Shamanov2019-02-13 14:10:25
Yandex maps
Anton Shamanov, 2019-02-13 14:10:25

How to make a window close when a button is clicked?

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.843363, 37.778445]
    ];
    $.each(coordinates, function (id, coordinates) {
        pickups.features.push({
            type: 'Feature', 
            id: id, 
            geometry: {type: 'Point', coordinates: coordinates}, 
            properties: {
                balloonContentBody: '...', 
                balloonContentFooter: '<a href="#" class="btn-select-pickup" data-id="'+id+'">Выбрать пункт</a>', 
                balloonContentHeader: 'ПВЗ №' + id, 
                clusterCaption: 'ПВЗ №' + id, 
                hintContent: 'ПВЗ №' + id
            }
        });
    });
    objManager.add(pickups);
    map.setBounds(map.geoObjects.getBounds());
    
    $('#map-pickups').on('click', '.btn-select-pickup', function (event) {
        event.preventDefault();
        $('#pickups-select').val($(this).data('id')).trigger('change');
        // осталось только закрыть окно :(
    });
});

Tell me how to add closing the window when the '.btn-select-pickup' button is pressed, I can't find it in the docks on api2 map events :(

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2019-02-13
@SilenceOfWinter

objManager.clusters.balloon.close();
objManager.objects.balloon.close();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question