2011-08-30 38 views
0

我的Google地圖運行良好。我一直試圖只讓一個infowindow立即打開,並在這樣做的過程中破壞了我的代碼。在這一點上,我無法恢復到工作階段。我經歷了十幾次代碼,找不到任何問題。我正在將我的更改放在stackoverflow論壇上的this article上。Google地圖:進行了更改,現在地圖不會加載

<script type="text/javascript"> 

    function initialize() { 
     var infowindow new google.maps.InfoWindow(); 
     var LatLng = new google.maps.LatLng(38.89, -92.343); 
     var myOptions = { 
      zoom: 13, 
      mapTypeId: google.maps.MapTypeId.ROADMAP, 
      center: LatLng 
     }; 

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

     var bounds = new google.maps.LatLngBounds();  

     var Image = "images/wrenchIcon.png"; 
     var Content = "blank"; 
     var Head = "The Falls"; 

     var cMarker = new google.maps.Marker({ 
      position: LatLng, 
      map: map, 
      title: Head, 
      icon: Image 
     }) 

     google.maps.event.addListenter(cMarker, 'click', function() { 
      infowindow.setContent(Content); 
      infowindow.open(map, cMarker); 
     }); 

      Image = "images/goodIcon.png"; 

      LatLng = new google.maps.LatLng(38.912, -92.301); 
      Content = "blank"; 
      Head = "Bob TheBuilder"; 

      var marker1 = new google.maps.Marker({ 
       position: LatLng, 
       map: map, 
       title: Head, 
       icon: Image 
      }); 

      google.maps.event.addListenter(marker1, 'click', function() { 
       infowindow.setContent(Content); 
       infowindow.open(map, marker1); 
      });  

      bounds.extend(LatLng); 

      Image = "images/alertYelIcon.png"; 

      LatLng = new google.maps.LatLng(38.951, -92.332); 
      Content = "blank"; 
      Head = "Shiloh Bar&Grill"; 

      var marker2 = new google.maps.Marker({ 
       position: LatLng, 
       map: map, 
       title: Head, 
       icon: Image 
      }); 

      google.maps.event.addListenter(marker2, 'click', function() { 
       infowindow.setContent(Content); 
       infowindow.open(map, marker2); 
      });  

      bounds.extend(LatLng); 

      Image = "images/goodIcon.png"; 

      LatLng = new google.maps.LatLng(38.92, -92.332); 
      Content = "blank"; 
      Head = "FlatBranch Pub"; 

      var marker3 = new google.maps.Marker({ 
       position: LatLng, 
       map: map, 
       title: Head, 
       icon: Image 
      }); 

      google.maps.event.addListenter(marker3, 'click', function() { 
       infowindow.setContent(Content); 
       infowindow.open(map, marker3); 
      });  

      bounds.extend(LatLng); 
</script> 
+0

我知道這篇文章是非常具體的,但任何你可以做的事情都會有所幫助,我要把我的頭撞在牆上。 – atk3kf

回答

0

它看起來像你的初始化函數沒有關閉}如果不是當被調用的函數問題,onload事件?

+0

我把結束括號,但它仍然不會加載。我注意到,有時會有一個灰色的輪廓,如果地圖不加載,其他時間則沒有任何內容。有了這個特殊的問題,什麼都沒有。在接下來的幾行代碼中,javascript是body標籤' – atk3kf

+0

那麼我建議你仔細檢查是否有1個(只有1個)div,id爲「map_canvas」,然後粘貼js(減去

0

它也看起來像你在初始化函數的第一行中缺少=

+0

當然。我剛剛意識到我一直在看這段代碼的過程,那個錯誤盯着我。 – atk3kf