1
我有一個谷歌地圖設置,其中的數據來自mySql後端,我存儲在編碼字符串中。 我可以正確顯示地圖中的數據,但無法提供外部鏈接。谷歌地圖infowindow的外部鏈接
for (x = 0; x < stringArray.length; x = x + 1)
{
var addressDetails = [];
var marker;
//Separate each field
addressDetails = stringArray[x].split("&&&");
//Load the lat, long data
var lat = new google.maps.LatLng(addressDetails[1], addressDetails[2]);
//Create a new marker and info window
var y = x+1;
marker = new google.maps.Marker({
map: map,
position: lat,
content: addressDetails[0],
icon: 'http://chart.apis.google.com/chart?chst=d_map_pin_letter&chld='+y+'|FF0000|000000'
});
//Pushing the markers into an array so that it's easier to manage them
markersArray.push(marker);
google.maps.event.addListener(marker, 'click', function() {
closeInfos();
var info = new google.maps.InfoWindow({content: this.content});
//On click the map will load the info window
info.open(map,this);
infos[0]=info;
});
//Extends the boundaries of the map to include this new location
bounds.extend(lat);
}
//Takes all the lat, longs in the bounds variable and autosizes the map
map.fitBounds(bounds);
而這段代碼是用於外部點擊的。
function myclick(i) {
google.maps.event.trigger(markersArray[i], "click");
}
我得到的錯誤是:「:沒有定義了MyClick未捕獲的ReferenceError」
請指導,我已經出了錯 ?
感謝,
任何幫助將不勝感激。 – ankitjain11
你在哪裏綁定'myclick'? –
我沒有得到你,對不起。你是說,我在哪裏打電話給這個活動? – ankitjain11