我與谷歌地圖API初學者,寫了這段JavaScript代碼顯示一個簡單的路線圖,向最終用戶:
如何添加點擊監聽器到谷歌地圖道路?
var originLatLng = new google.maps.LatLng(OrginLat, OrginLng);
var destinationLatLng = new google.maps.LatLng(DestLat, DestLng);
directionsService.route({
origin: originLatLng,
destination: destinationLatLng,
travelMode: google.maps.DirectionsTravelMode.DRIVING
}, function (response, status) {
if (status === google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
} else {
window.alert('Directions request failed due to ' + status);
}
});
}//end of function
現在我想啓用的道路上點擊事件。例如,當用戶點擊道路時,顯示警報。我如何編寫該代碼?謝謝大家。
我不知道答案given..next TYM同時給予解答 –