2011-08-31 6 views
0

Google지도는 처음에만 잘 표시됩니다. 두 번째 또는 그 이상 라인을 클릭하면지도가 제대로 다시 그려지지 않으므로 쓸모가 없습니다. google.maps.event.trigger (지도 '크기 조정')으로Google지도 다시 그리기 오류

var myLatlng = new google.maps.LatLng(53.3820845337596, -1.46965489864111); 
     var myOptions = { 
      zoom: 15, 
      center: myLatlng, 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      scrollwheel:false 
     } 

     var map  = new google.maps.Map(document.getElementById("map_canvas"), myOptions); 

     var marker = new google.maps.Marker({ 
       position: myLatlng, 
       map: map, 
       title: 'we are right here ...' 
     }); 

     var myLatlng2 = new google.maps.LatLng(53.3820845337596, -1.46965489864111); 

     marker.setMap(map); 

     google.maps.event.addListener(marker, 'click', function(){ 
     infowindow.open(map, marker); 
     }); 

     google.maps.event.trigger(map, 'resize'); 

;

나는 다음과 같은 코드를 사용하고 결국 내 시도가 제대로 작동하도록지도를 얻는 것입니다.

효과는 http://test2omniforce.co.uk/node/8에서 볼 수 있으며지도 이미지를 클릭하면 볼 수 있습니다.

누구든지 도움을 줄 수 있습니까?

답변

0

너의 div에 map.php의 id 'map_canvas'로 너비와 높이가 설정되지 않은 것 같습니다. 이것이지도가 올바르게 렌더링되지 않는 원인인지 궁금합니다.

일부 특성 항목을 추가하여 해당 기능이 작동하는지 확인해보십시오.

행운을 빈다.

+0

div # map_canvas의 CSS에는 너비 800px 및 높이 500px가 설정되어 있습니다. – sisko