K
K
KevinSmash2019-07-29 19:40:23
JavaScript
KevinSmash, 2019-07-29 19:40:23

How to add a button to a label in Yandex maps?

Good day. You need to add a large number of tags to Yandex maps. json example:

"type": "FeatureCollection",
      "features": [

        {"type": "Feature", "id": 0, "geometry": {"type": "Point", "coordinates": [52.651061, 90.088644]}, "properties": {"balloonContentHeader": "<font size=3>Название точки: Westfalika</font>", "balloonContentBody": "<p class=\"address\">Адрес: Респ Хакасия, г Абаза, ул Лазо, дом 1</p><p>Режим работы: ежедневно 09.00-18.00</p><p>Оплата: Наличные, карта</p><br />"}},

        {"type": "Feature", "id": 1, "geometry": {"type": "Point", "coordinates": [53.719807, 91.436978]}, "properties": {"balloonContentHeader": "<font size=3>Название точки: Ростелеком</font>", "balloonContentBody": "<p class=\"address\">Адрес: Респ Хакасия, г Абакан, ул Советская, дом 45</p><p>Режим работы: Пн-Пт 09.00-18.00  Сб,Вс выходной</p><p>Оплата: Наличные</p><br />"}},

All labels are displayed, but now I need to create a button and save the value of the label (address, working time) in Post. Accordingly, it is necessary to create a button in the label itself, which would save the value in POST? Here is the processing js file
ymaps.ready(function () {
    var map;
    ymaps.geolocation.get().then(function (res) {
        var mapContainer = $('#map'),
            bounds = res.geoObjects.get(0).properties.get('boundedBy'),
            mapState = ymaps.util.bounds.getCenterAndZoom(
                bounds,
                [mapContainer.width(), mapContainer.height()]
            );
        createMap(mapState);
    }, function (e) {
        createMap({
            center: [55.751574, 37.573856],
            zoom: 9
        });
    });

    function createMap (state) {
        var myMap = new ymaps.Map('map', state);
        objectManager = new ymaps.ObjectManager({
            clusterize: true,
            gridSize: 32,
            clusterDisableClickZoom: true
        });

        objectManager.objects.options.set('preset', 'islands#greenDotIcon');
        objectManager.clusters.options.set('preset', 'islands#greenClusterIcons');
        myMap.geoObjects.add(objectManager);

        $.ajax({
            url: "data.json"
        }).done(function (data) {
            objectManager.add(data);
        });
    }
});

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question