0
我有一個右鍵單擊上下文菜單的偵聽器,該菜單允許我執行特定於該特定infowindow的操作。舉例來說,這裏是我的代碼打開並填補了方向面板:GoogleMaps API v3 - Infowindow中的鏈接觸發事件
google.maps.event.addListener(contextMenu, 'menu_item_selected', function(latLng, eventName){
switch(eventName){
case 'directions_from_click':
showDirections();
geocoder.geocode({latLng: latLng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
fAddress = results[0].formatted_address;
$('#start').val(fAddress);
$('#panelWrapper').focus();
}
}
});
$('#panelWrapper').focus();
break;
case 'directions_to_click':
showDirections();
geocoder.geocode({latLng: latLng}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
if (results[0]) {
fAddress = results[0].formatted_address;
$('#end').val(fAddress);
$('#panelWrapper').focus();
}
}
});
$('#panelWrapper').focus();
break;
}
});
除了右鍵單擊快捷菜單,我也想有在該信息窗口的onclick執行相同操作的鏈接:
<a class="fromLink">Directions from here</a>
如何爲此鏈接添加一個偵聽器來執行類似於我的上下文菜單的偵聽器?我一直在嘗試addDomListener函數,但我不確定這是否正是我需要的。