Geo objects are created on the map. These objects have a unique for each id and when clicked, a popup opens with information about the object ( http://clip2net.com/s/3PWEiom ). Please tell me how you can hide, make it visible again and emulate a click on this geo object knowing its id (for example, id = "place-1"). Here is the code for creating objects on the map
(function ($) { "use strict"; ymaps.ready(init); var data = []; var $mapBlock = $('.js-map'); function init() { var defaultCoords = [55.76, 37.64]; var userCoords = defaultCoords; //Список городов var citys = {}; $('.js-dealers-cities').each(function() { var city = $(this).data('city-name'); var lat = $(this).data('city-lat'); var lng = $(this).data('city-lng'); citys[city] = {}; citys[city]['lat'] = lat; citys[city]['lng'] = lng; }); var geolocation = ymaps.geolocation, myMap = new ymaps.Map('map', { center: defaultCoords, zoom: 12, controls: [] }), objectManager = new ymaps.ObjectManager({ // Чтобы метки начали кластеризоваться, выставляем опцию. clusterize: false, geoObjectOpenBalloonOnClick: true, clusterOpenBalloonOnClick: false }); myMap.controls.add('zoomControl', { position: { right: 10, bottom: 110 } }); geolocation.get({ provider: 'yandex', mapStateAutoApply: false //true - автоматом центровать по положению пользователя }).then(function (result) { //Координаты пользователя userCoords = result.geoObjects.position; myMap.setCenter (userCoords, 6, {flying: true, duration: 0}); }});
myMap.geoObjects.add(objectManager); $mapBlock.find('.map-point').each(function () { var $that = $(this); var coords = $(this).data('coords').split(','); if (!Layout.isDesktopLayout()) { data.push({ "type": "Feature", "id": $that.data('id'), "geometry": { "type": "Point", "coordinates": coords } }); } else { data.push({ "type": "Feature", "id": $that.data('id'), "geometry": { "type": "Point", "coordinates": coords }, "properties": { "balloonContent": $that.html() } }); } }); objectManager.add(data); function onObjectEvent(id) { console.log(id); objectManager.objects.setObjectOptions(id, { balloonOffset: [-105, -35], hideIconOnBalloonOpen: false, balloonAutoPanMargin: 5, iconLayout: 'default#image', iconImageHref: '/themes/frontend/html/static/images/map-point.svg', iconImageSize: [25, 38], iconContentOffset: [-12, -19] }); } function openPopup(e) { if (!Layout.isDesktopLayout()) { Popups.openById(e.get('objectId')); } } $mapBlock.find('.map-point').each(function () { objectManager.objects.events.fire('click', onObjectEvent($(this).data('id'))); }); objectManager.objects.events.add('click', openPopup); } }) (jQuery);