Answer the question
In order to leave comments, you need to log in
Balloons not showing up when clicking on a label?
Good afternoon, I wrote down a post on Yandex in the mapapi club , but so far I haven’t received an answer there, why do n’t my balloons show up?
I use the code from the example, almost 1 in 1:
$(function(){
ymaps.ready(init);
var map = null;
$("#'.$mapDialog->id.'").on("shown.bs.modal", function(e){
// Изменим размеры контейнера карты
//map.container.getElement().style.width = "500px";
//map.container.getElement().style.height = "450px";
// Инициируем пересчет размеров
if (map)
map.container.fitToViewport();
});
function init() {
var balloons = '. json_encode($this->balloons).';
$("#'.$this->triggerId.',.'.$this->triggerClass.'").removeClass("disabled");
$("#'.$this->triggerId.',.'.$this->triggerClass.'").on("click",
function () {
if (map == null) {
ymaps.modules.require(["Map", "Placemark"]).spread(function(Map, Placemark) {
map = new ymaps.Map("simple-map", {
center: ['.$this->centerFi.', '.$this->centerLam.'],
zoom: '.$this->zoom.',
});
for (i=0; i<balloons.length; i++ ){
var placemark = new Placemark(
[balloons[i].coordFi, balloons[i].coordLam], {
balloonContentHeader : balloons[i].balloonContentHeader,
balloonContentBody : balloons[i].balloonContentBody,
//balloonContentFooter : blloons[i].balloonContentFooter,
hintContent : balloons[i].hintContent,
//balloonContent : balloons[i].hintContent,
}, {
hasBalloon : true,
openEmptyBalloon : true,
openEmptyHint : true,
openHintOnHover : true,
syncOverlayInit : true,
visible : true,
});
map.geoObjects.add(placemark);
}
},this)
} else {
map.destroy();// Деструктор карты
map = null;
}
});
$("#'.$mapDialog->id.'").on("hidden.bs.modal", function (e) {
if (map) {
map.destroy();// Деструктор карты
map = null;
}
})
}
});
Answer the question
In order to leave comments, you need to log in
Judging by the code, you are connecting the API not with package.full?
Then you need to additionally load balloon addons for those objects to which you want to assign balloons. In particular, map.addon.balloon and geoObject.addon.balloon
https://tech.yandex.ru/maps/doc/jsapi/2.1/ref/ref...
https://tech.yandex.ru/maps/ doc/jsapi/2.1/ref/refe...
The same with the hint and editors.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question