2010-07-13 24 views
0

我不知道這是爲什麼。谷歌地圖 - 不能正常顯示,但已下載HTML格式

但由於某種原因,我的谷歌地圖腳本加載在頁面中,但它不顯示。

我很好奇我做錯了什麼。

這是我的html。

<ul class="address"> 
<LI><STRONG>Titel:</STRONG><br/>Text 
<div class="gmap" address="Stationsstraat 23 8780 Oostrozebeke"></div></LI> 
</ul> 
<ul class="address"> 
<LI><STRONG>Titel:</STRONG>Text 
<div class="gmap" address="Eredekestraat 56 2000 Antwerpen"></div></LI></UL> 

下面是我的JavaScript(用jQuery):

 $(document).ready(function(){ 
     var coll_gmap = $(".gmap"); 
     if (coll_gmap.length != 0) 
     { 
      //initiate map 
      geocoder = new google.maps.Geocoder(); 
      var latlng = new google.maps.LatLng(-34.397, 150.644); 
      var myOptions = { 
       zoom: 8, 
       center: latlng, 
       mapTypeId: google.maps.MapTypeId.ROADMAP 
      } 

      //loop all addressen + insert into map 
      coll_gmap.each(function(index) 
      { 
       map = new google.maps.Map(coll_gmap[0], myOptions); 
       if (geocoder) { 
         geocoder.geocode({ 'address': $(this).attr("address")}, function(results, status) { 
          if (status == google.maps.GeocoderStatus.OK) { 
           map.setCenter(results[0].geometry.location); 
           var marker = new google.maps.Marker({ 
            map: map, 
            position: results[0].geometry.location 
           }); 
          } else { 
           alert("Geocode was not successful for the following reason: " + status); 
          }//end if status 
         }); //end if geocoder.geocode 
        } //end if geocoder 

      }) //end coll_gmap each 

      }//end if coll_gmap length 
    }); //end onload 


    var geocoder, map; 
+0

你什麼錯誤信息? – 2010-07-13 10:00:21

+0

我並沒有任何錯誤消息:( – NicoJuicy 2010-07-13 10:55:19

回答

2

破HTML。沒有你的div是封閉的,而這完全是錯誤的:</ </LI></UL>

+0

即使你說的是正確的( NicoJuicy 2010-07-13 10:55:59

3

我發現它是什麼。

我必須把我的寬度和高度上

<div> =>(becomes)=> 
<div style="width:500px;height:150px"></div> 

簡單算了,我猜:(