Google舉了一個例子 http://googlemapsapi.blogspot.com/2007/05/driving-directions-support-added-to.html谷歌地圖駕駛方向源代碼爲他們的例子?
源代碼是否在某個地方可用,或者有關該精確示例的教程?
Google舉了一個例子 http://googlemapsapi.blogspot.com/2007/05/driving-directions-support-added-to.html谷歌地圖駕駛方向源代碼爲他們的例子?
源代碼是否在某個地方可用,或者有關該精確示例的教程?
下面是一個使用非常簡單的例子在v3 API:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<title>Google Maps API v3 Directions Example</title>
<script type="text/javascript"
src="http://maps.google.com/maps/api/js?sensor=false"></script>
</head>
<body style="font-family: Arial; font-size: 12px;">
<div style="width: 600px;">
<div id="map" style="width: 280px; height: 400px; float: left;"></div>
<div id="panel" style="width: 300px; float: right;"></div>
</div>
<script type="text/javascript">
var directionsService = new google.maps.DirectionsService();
var directionsDisplay = new google.maps.DirectionsRenderer();
var map = new google.maps.Map(document.getElementById('map'), {
zoom:7,
mapTypeId: google.maps.MapTypeId.ROADMAP
});
directionsDisplay.setMap(map);
directionsDisplay.setPanel(document.getElementById('panel'));
var request = {
origin: 'Chicago',
destination: 'New York',
travelMode: google.maps.DirectionsTravelMode.DRIVING
};
directionsService.route(request, function(response, status) {
if (status == google.maps.DirectionsStatus.OK) {
directionsDisplay.setDirections(response);
}
});
</script>
</body>
</html>
截圖:
謝謝,這正是我想要的:學習的簡約例子。 – user310291 2010-10-10 08:12:15
嗨,我可以添加更多的一個目的地爲同一個來源,並獲得所有目的地的路線方向在一次.. – manju 2011-02-07 05:11:37
@danial vassallo Thanx爲這個有用的答案。它是否具有語言選項以供它提供的響應輸出。 – hardik 2012-07-06 16:57:27
你打算使用V2 API或V3?後者是推薦的,因爲V2已被棄用。 – 2010-10-09 16:44:21
V3如果推薦。我現在在學習,所以我想要一些源代碼。 – user310291 2010-10-09 17:24:40
請給一個鏈接以獲取源代碼來理解! – 2012-03-20 06:06:42