2013-07-26 143 views
0

我已經使用編碼多個標記,我需要自定義信息窗口,現在顯示默認的。我需要自定義窗口的背景圖像,並與鏈接谷歌地圖整合與自定義infowindow多標記

 <script type="text/javascript"> 
     var locations = [['chennai', 13.0810, 80.2740, 4], 
     ['madurai', 9.9300, 78.1200, 5], 
     ['coimbatore', 11.0183, 76.9725, 3], 
     ['Trichy', 10.8100, 76.9725, 2], 
     ['vellore', 12.9202, 79.1333, 1]]; 

     var map = new google.maps.Map(document.getElementById('map'), { 
     zoom: 10, 
     center: new google.maps.LatLng(13.0810, 80.2740), 
     mapTypeId: google.maps.MapTypeId.ROADMAP 
    }); 

    var infowindow = new google.maps.InfoWindow(); 

    var marker, i; 
var icon='images/'; 
for (i = 0; i < locations.length; i++) { 
    marker = new google.maps.Marker({ 
    position: new google.maps.LatLng(locations[i][1], locations[i][2]), 
    icon: icon + 'pin.png', 
    map: map 
    }); 

    google.maps.event.addListener(marker, 'click', (function(marker, i) { 
    return function() { 
     infowindow.setContent(locations[i][0]); 
     infowindow.open(map, marker); 
    } 
    })(marker, i)); 
    } 
</script> 

回答

0

你可以把你喜歡的東西HTML wise到您使用該調用創建信息窗口。

infowindow.setContent(locations[i][0]); 

所以,你可以舉例來說做到這一點

var info = '<div class="mybackground">' + 
'<div>Hello World</div> 
'<div><a href="url">Link</a></div> 
'<div>'; 
infowindow.setContent(info);