本文介绍了Google地图驾驶方向源代码为他们的例子?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Google举了一个例子



源代码是否可用于某处或某处关于该精确示例的教程?

解决方案

以下是使用:

 <!DOCTYPE html> < HTML> < HEAD> < meta http-equiv =content-typecontent =text / html; charset = UTF-8/> < title> Google Maps API v3路线示例< / title> < script type =text / javascriptsrc =http://maps.google.com/maps/api/js?sensor=false>< / script> < /头> < body style =font-family:Arial; font-size:12px;> < div style =width:600px;> < div id =mapstyle =width:280px; height:400px; float:left;>< / div> < div id =panelstyle =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(地图); directionsDisplay.setPanel(的document.getElementById(面板)); 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);}}); < /脚本> < /体> < / html>  



屏幕截图:
$ b

Google gave an examplehttp://googlemapsapi.blogspot.com/2007/05/driving-directions-support-added-to.html

Is the source code available somewhere or a tutorial on that precise example ?

解决方案

Here's a very basic example using the 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>

Screenshot:

这篇关于Google地图驾驶方向源代码为他们的例子?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 16:49