1

这是我的脚本:

// InfoWindow content
var content = '<div id="iw-container">' +
             '<div class="iw-title">Porcelain Factory of Vista Alegre</div>' +
                    '<div class="iw-content">' +
                      '<div class="iw-subTitle">History</div>' +
                      '<img src="images/vistalegre.jpg" alt="Porcelain Factory of Vista Alegre" height="115" width="83">' +
                      '<p>Founded in 1824, the Porcelain Factory of Vista Alegre was the first industrial unit dedicated to porcelain production in Portugal. For the foundation and success of this risky industrial development was crucial the spirit of persistence of its founder, José Ferreira Pinto Basto. Leading figure in Portuguese society of the nineteenth century farm owner, daring dealer, wisely incorporated the liberal ideas of the century, having become "the first example of free enterprise" in Portugal.</p>' +
                      '<div class="iw-subTitle">Contacts</div>' +
                      '<p>VISTA ALEGRE ATLANTIS, SA<br>3830-292 Ílhavo - Portugal<br>'+
                      '<br>Phone. +351 234 320 600<br>e-mail: geral@vaa.pt<br>www: www.myvistaalegre.com</p>'+
                    '</div>' +
                    '<div class="iw-bottom-gradient"></div>' +
                  '</div>';
// A new Info Window is created and set content
var infowindow = new google.maps.InfoWindow({
    content: content
});
...
google.maps.event.addListener(marker, 'click', function() {
   infowindow.open(map,marker);
});

这是我的 slimScroll 脚本(http://rocha.la/jQuery-slimScroll

$(function(){
    $('#iw-container').slimScroll({
        allowPageScroll: true, 
        height: '100px',
        disableFadeOut: true
     });
});

但结果不起作用,如何解决?

错误 SlimScroll

4

1 回答 1

1

至少该插件在寻找新元素时有超时(看起来没有),当 infowindow html 附加到 DOM 时,您将不得不调用该插件。

此外,正如@Starscream1984 所说,请注意您选择的元素。

请参阅一个工作示例(jsfiddle)

google.maps.event.addListener(infowindow, 'domready', function(){
    $('.target_element').slimScroll({
        allowPageScroll: true, 
        height: '50px',
        disableFadeOut: true
    });
});
于 2015-09-15T16:16:44.027 回答