2009-04-19 3 views
0

안녕하세요 두꺼운 상자를 googlemaps의 오버레이에 추가하려고합니다. 내 JQuery onload 함수에서 다음 함수를 호출합니다. 지도 잘 작동합니다. 그러나 두꺼운 상자는 불리지 않는 것 같습니다. 이js 파일에서 thickbox 호출

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

전체 기능

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(); 
    } 
+0

예제 소스 코드 – pocheptsov

+0

을 명확히하여 제 게시물을 엉망으로 만드십시오. 나는 그것을 업데이트했습니다 :) – frosty

답변

2

당신은 당신이 Thickbox와 기능이 이미 호출 된 후 DOM에 Thickbox와를 활성화 할 링크를 추가하는 작업 않는 라인입니다. 이는 map.openInfoWindowHtml 함수 내에서 동적으로 링크를 생성하기 때문입니다. 이 함수가 실행 된 후에는 thickbox 함수를 호출해야합니다.

문제는 방금 thickbox 문서에서 보았고 thickbox는 DOM이 너무 빨리로드되는 즉시 thickbox.js 파일 내에서 설정됩니다.

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

내가이 작동 100 % 확실하지 못할,하지만이 문제의 핵심입니다 : 당신이에서는 setTimeout 기능을 변경을 시도 할 수 있습니다.

+0

당신은 절대적으로 맞습니다. 새로 생성 된 thickbox 요소는 tb_init 함수로 초기화해야합니다. 그/그녀는 자신의 코드에 다른 문제가 있지 않으면 작동하지 않아야 할 이유가 없습니다. – KyleFarris

관련 문제