我正在尝试向气球添加一个按钮,该按钮将清除地图上的所有标记并在按下它的位置生成一个新标记,但它不起作用 - 浏览器发誓没有这样的功能(据我所知它,生成的按钮不能从外部文件执行功能)。告诉我,这个问题有什么漂亮的解决方案吗?到目前为止,当您单击标签本身时,我已经使所需的功能起作用,但我不太喜欢这个选项。
res.geoObjects.each(function (item) {
console.log(item.geometry.getCoordinates());
if (item.getPremiseNumber()) {
var tempPlacemark = new ymaps.Placemark(item.geometry.getCoordinates(), {balloonContent: item.getAddressLine() + '<br><button class="btn btn-secondary btn-sm mt-1" onclick="getAddress(\'' + item.geometry.getCoordinates() + '\')">выбрать</button>'})
} else {
var tempPlacemark = new ymaps.Placemark(item.geometry.getCoordinates(), {balloonContent: item.getAddressLine()})
}
searchCollection.add(tempPlacemark);
});