Answer the question
In order to leave comments, you need to log in
Why can't the map be shown on click?
Hello!
Please tell me what the problem might be:
We have: We
load the div1 layer with ajax , this layer has a link link and another hidden layer div2 , when you click on the link (we get the map layer id from the link) we show the hidden div2 layer and initialize the map .
<div id="div1">
<a href="#" id="link"><!-- По клику на эту ссылку мы создаём/показываем карту --></a>
<div id="div2"><!-- Сюда грузится карта --></div>
</div>
function init() {
var myMap
tcName = $(this).attr('class'),
tid = tcName.split(/\s+/)[1];
// ... и другие переменные
$('#show_fmap').bind({
click: function(e) {
e.preventDefault();
// здесь идёт код (если надо, могу выложить)
myMap = new ymaps.Map(tid, {
center: [55.75399400, 37.62209300],
zoom: 9,
controls: ["trafficControl", "typeSelector", "rulerControl"]
});
// здесь идёт код (если надо, могу выложить)
});
}
ymaps.ready(init);
Answer the question
In order to leave comments, you need to log in
You have some strange code, but here are the steps how to do it:
1. Initially hide the map display button
2. In the function call, init
show the button and hang the handler (you can hang the handler earlier, but I don’t see the point until the map is prepared)
3. On click, we create a map and show it.
If you do everything correctly and in order, then everything should work correctly
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question