谷歌地图驾驶方向源代码为他们的例子?
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