2014-04-25 55 views
1

我很難找到一種方法來超鏈接我的infowindow中的文本。我嘗試過window.location.href命令,但我不想鏈接標記本身,因爲我需要鏈接文本。我花了一個小時的Google搜索,但還沒有找到一個這樣做的方法。任何幫助將不勝感激:)我的代碼如下。出現在infowindows中的文本位於內容字符串變量中。如何鏈接(谷歌地圖)infowindow文本字符串?

三江源, 安東尼

function allbrisbaneparks() { 
    var myLatlng1 = new google.maps.LatLng(-27.51561168,153.0593704); 
    var myLatlng2 = new google.maps.LatLng(-27.59129579,153.0463111); 
    var myLatlng3 = new google.maps.LatLng(-27.45968511, 153.0505714); 
    var mapOptions = { 
    zoom: 10, 
    center: myLatlng1 
    }; 

    var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); 

    var contentString1 = 'Mott Park' 
    var contentString2 = 'Bushy Park' 
    var contentString3 = "Catalina Park" 

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

    var marker1 = new google.maps.Marker({ 
     position: myLatlng1, 
     map: map, 
     title: 'Mott Park' 
    }); 
    var marker2 = new google.maps.Marker({ 
     position: myLatlng2, 
     map: map, 
     title: 'Bushy Park' 
    }); 
    var marker3 = new google.maps.Marker({ 
     position: myLatlng3, 
     map: map, 
     title: 'Catalina Park' 
    }); 
    function addmarker(identity, content){ 
     google.maps.event.addListener(identity, 'click', function allbrisbaneparks() { 
     infowindow.close();//hide the infowindow 
     infowindow.setContent(content);//update the content for this marker 
     infowindow.open(map, identity); 

}); 
} 
addmarker(marker1, contentString1) 
addmarker(marker2, contentString2) 
addmarker(marker3, contentString3) 
} 
function domlistenerbrisbane(){ 
    google.maps.event.addDomListener(window, 'load', allbrisbaneparks); 
} 

回答

0

修改您的contentStrings到:

var contentString = '<a href="your URL" >The address name</a>';