Yandex 地图 API点击获取地标标题

问题描述

我想通过点击获取地标标题或气球。 这是我的功能

function init() {
    var myMap = new ymaps.Map("map",{
        center: [55.76,37.64],zoom: 10
     });

     myMap.geoObjects
     .add(new ymaps.Placemark([55.684758,37.738521],{
         iconCaption: '111 title',balloonContent: '111 content'
                                                                
     }))
     .add(new ymaps.Placemark([55.687086,37.529789],{
        iconCaption: '222 title',balloonContent: '222 content'
                                                                
     }));
     var objectManager = new ymaps.ObjectManager( {} );
     objectManager.events.add(['click'],function(event){

         var title = //get Placemark title

         console.log(title);

     });
     myMap.geoObjects.add( objectManager );
}

更新: 我将此代码添加到地标:

balloonContentBody: '111 content<br><button class="selectPlacemark">Select</button>'

然后通过点击这个按钮我得到气球内容。但这不是我喜欢的解决方

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)