2017-07-01 170 views
-1

我試圖在Google地圖信息窗口中顯示圖像滑塊。但沒有錯誤,但滑塊不起作用。在谷歌地圖信息窗口中運行圖像滑塊

我想要做的和圖片一樣。

$(document).ready(function() { // runs jquery when document is ready 

     function initialize() { 

     var uluru = { 
      lat: -25.363, 
      lng: 131.044 
     }; 
     var map = new google.maps.Map(document.getElementById('map'), { 
      zoom: 4, 
      center: uluru 
     }); 

     var contentString = '<div id="content"><ul id="slider"><li><img src="demos/images/slide-civil-1.jpg" alt=""></li><li><img src="demos/images/slide-env-1.jpg" alt=""></li><li><img src="demos/images/slide-civil-2.jpg" alt=""></li><li><img src="demos/images/slide-env-2.jpg" alt=""></li></ul></div>'; 

     var infowindow = new google.maps.InfoWindow({ 
      content: contentString 
     }); 

     var marker = new google.maps.Marker({ 
      position: uluru, 
      map: map, 
      title: 'Uluru (Ayers Rock)' 
     }); 
     marker.addListener('click', function() { 
      infowindow.open(map, marker); 
     }); 

     google.maps.event.addListener(infowindow, function() { 
      $('#slider').anythingSlider(); 

     }); 
     } 
     initialize(); 

    }); 

enter image description here

+0

(」 #slider')。anythingSlider();'在infowindow的'domready'事件上(你在你的事件監聽器中缺少事件名稱) – geocodezip

+0

請使它成爲答案,我想給你+1並接受ans –

+0

和誰給我-1。來這裏解釋理由 –

回答

1

您需要在domready事件的信息窗口的運行$('#slider').anythingSlider();(你缺少你的事件偵聽器的事件名稱),你需要運行`$

google.maps.event.addListener(infowindow, "domready", function() { 
     $('#slider').anythingSlider(); 
});