Pergunta

Oi eu estou tentando adicionar caixa de espessura a uma sobreposição em googlemaps. Em função meu JQuery onload i chamar a seguinte função. O mapa funciona bem. Mas quando a caixa de espessura não parece ser chamado. Esta é a linha que faz o trabalho

<a href="test.html?keepThis=true&TB_iframe=true&height=250&width=400" title="add a caption to title attribute / or leave blank" class="thickbox">Example 1</a>

Toda a função

function load(lat, lng, zlevel, userKey, state) {

        map = new GMap2(document.getElementById("map"));
        map.disableDoubleClickZoom();
        map.setCenter(new GLatLng(lat, lng), zlevel);

        if (state) {

            dsp = true;

            map.addControl(new GLargeMapControl());
            GEvent.addListener(map, "click", function(overlay, latlng) {

                var zoom = map.getZoom();
                var display = '<h5 class="header-flag">Flag</h5><p class="maptext"><a href="#" onclick="javascript:openOverlay(' + latlng.lat() + ',' + latlng.lng() + ',' + zoom + ');">Click here</a> to enter your comment - 
<a href="test.html?keepThis=true&TB_iframe=true&height=250&width=400" title="add a caption to title attribute / or leave blank" class="thickbox">Example 1</a></p>';

                setTimeout(function() { map.openInfoWindowHtml(latlng, display, { maxWidth: 200 }); }, 0);
            });
        } else {


        }

        mgr = new MarkerManager(map);
        loadMarkers(userKey);
        mgr.refresh();
    }
Foi útil?

Solução

Seu adicionar o link que você quer ativar o thickbox ao DOM após a função thickbox já foi chamado. Isso é porque você está criando o dinamicamente link dentro da função map.openInfoWindowHtml. Você precisa chamar a função thickbox após esta função foi executada.

O problema é que eu só olhei para os docs Thickbox e thickbox fica configurado dentro do arquivo thickbox.js assim que as cargas DOM que é cedo demais para você. Você poderia tentar alterar a função setTimeout a esta:

setTimeout(function() { map.openInfoWindowHtml(latlng, display, { maxWidth: 200 }); tb_init('a.thickbox'); }, 0);

Eu não posso ser 100% de certeza que isso vai funcionar, mas este é o cerne do problema.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top