N
N
Nik Master2022-02-16 07:14:18
Yandex maps
Nik Master, 2022-02-16 07:14:18

How to add labels from json to all maps?

Added several maps to the site. But from the documentation I could not connect the labels from my json file. Tell me how can I connect labels from json to all added cards? That is, all labels will be added, and the maps will differ only by city.

ymaps.ready(init);

function init () {
    var myMap = new ymaps.Map('map',
        // Параметры карты.
        {
            // Географические координаты центра отображаемой карты.
            center: [59.94, 30.32],
            // Масштаб.
            zoom: 10
        }, {
            // Поиск по организациям.
            searchControlProvider: 'yandex#search'
        });
    var myMap_pit = new ymaps.Map('map_pit',
        {
            // Географические координаты центра отображаемой карты.
            center: [55.755768, 37.617671],
            // Масштаб.
            zoom: 7
        }, {
            // Поиск по организациям.
            searchControlProvider: 'yandex#search'
        }
    );


Example lines from json:

{
    "type": "FeatureCollection",
    "features": [
        {"type":"Feature","id":0,"geometry":{"type":"Point","coordinates":[55.732368,38.063964]},"properties":{"balloonContentBody":"<div class='logo_header_map'><img class='logo_map' src='logo.png'></div><br><p class='width_title'>Ширина: 60</p><p class='width_desc'>Компания 'Clops' </p><a href='tel:+799988887766' class='width_phone1'>+7(888)999-88-66</a><br><br><a href='#' class='width_link'>Link Text</a>"}},
        {"type":"Feature","id":1,"geometry":{"type":"Point","coordinates":[55.728695,38.043708]},"properties":{"balloonContentBody":"<div class='logo_header_map'><img class='logo_map' src='logo.png'></div><br><p class='width_title'>Ширина: 80</p><p class='width_desc'>Компания 'Clops' </p><a href='tel:+799988887766' class='width_phone1'>+7(888)999-88-66</a><br><br><a href='#' class='width_link'>Link Text</a>"}}
]
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
F
freeExec, 2022-02-16
@freeExec

The very approach of displaying a bunch of cards is strange.
There is a label on the map in the examples, this is the first thing to look for
https://yandex.ru/dev/maps/jsbox/2.1/object_manager

V
Vladislav Orlov, 2022-02-16
@haveacess

I agree with the previous speaker. Crowding a bunch of cards on one page is not a good idea. Moreover, if you split points by city.
It would be much more logical to display one card and always use it.
Those. put the necessary markers depending on the conditions

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question