Question

Salut je suis en train d'ajouter boîte épaisse à une superposition dans googlemaps. Sur ma fonction JQuery onload j'appelle la fonction suivante. La carte fonctionne très bien. Mais lorsque la boîte épaisse ne semble pas être appelé. Ceci est la ligne qui fonctionne

<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>

La fonction entière

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();
    }
Était-ce utile?

La solution

Votre ajout du lien que vous souhaitez activer le thickbox au DOM après la fonction thickbox a déjà été appelé. En effet, vous créez le lien dynamique au sein de la fonction map.openInfoWindowHtml. Vous devez appeler la fonction thickbox après cette fonction a été exécutée.

Le problème est que je juste regardé les Thickbox docs et thickbox fichier est mis en place dans les thickbox.js dès que les charges DOM qui est trop tôt pour vous. Vous pouvez essayer de modifier la fonction setTimeout à ceci:

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

Je ne peux pas être à 100% sûr que cela fonctionnera, mais c'est le nœud du problème.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top