zoukankan      html  css  js  c++  java
  • google地图路径查询

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <title></title>
        <style type="text/css">
          html { height: 100% }
          body { height: 100%; margin: 0; padding: 0 }
          #map-canvas { height: 100% }
        </style>
        <script type="text/javascript"
          src="https://maps.googleapis.com/maps/api/js?key=AIzaSyDdIlaRp0Dm8cEP8oXZ_8HLuj_zpccK7gw&sensor=true">
        </script>
        <script type="text/javascript">
            var directionsDisplay;
            var directionsService = new google.maps.DirectionsService();
            var map;
            function initialize() {
                directionsDisplay = new google.maps.DirectionsRenderer();
                var chicago = new google.maps.LatLng(41.850033, -87.6500523);
    
                var mapOptions = {
                    center: chicago,
                    zoom: 18,
                    mapTypeId: google.maps.MapTypeId.ROADMAP
    
                };
                map = new google.maps.Map(document.getElementById("map-canvas"), mapOptions);
                directionsDisplay.setMap(map);
    
    
            }
            function calcRoute() {
                var start = document.getElementById("start").value;
                var end = document.getElementById("end").value;
                var request = {
                    origin: start,
                    destination: end,
                    travelMode: google.maps.TravelMode.DRIVING
                };
                directionsService.route(request, function (result, status) {
                    if (status == google.maps.DirectionsStatus.OK) {
                        directionsDisplay.setDirections(result);
                    }
                });
            }
    
            
            google.maps.event.addDomListener(window, 'load', initialize);
    
        </script>
    </head>
    <body>
    <div>
    <strong>Start: </strong>
    <select id="start" onchange="calcRoute();">
      <option value="chicago, il">Chicago</option>
      <option value="st louis, mo">St Louis</option>
      <option value="joplin, mo">Joplin, MO</option>
      <option value="oklahoma city, ok">Oklahoma City</option>
      <option value="amarillo, tx">Amarillo</option>
      <option value="gallup, nm">Gallup, NM</option>
      <option value="flagstaff, az">Flagstaff, AZ</option>
      <option value="winona, az">Winona</option>
      <option value="kingman, az">Kingman</option>
      <option value="barstow, ca">Barstow</option>
      <option value="san bernardino, ca">San Bernardino</option>
      <option value="los angeles, ca">Los Angeles</option>
    </select>
    <strong>End: </strong>
    <select id="end" onchange="calcRoute();">
      <option value="chicago, il">Chicago</option>
      <option value="st louis, mo">St Louis</option>
      <option value="joplin, mo">Joplin, MO</option>
      <option value="oklahoma city, ok">Oklahoma City</option>
      <option value="amarillo, tx">Amarillo</option>
      <option value="gallup, nm">Gallup, NM</option>
      <option value="flagstaff, az">Flagstaff, AZ</option>
      <option value="winona, az">Winona</option>
      <option value="kingman, az">Kingman</option>
      <option value="barstow, ca">Barstow</option>
      <option value="san bernardino, ca">San Bernardino</option>
      <option value="los angeles, ca">Los Angeles</option>
    </select>
    </div>
    
        <div id="map-canvas"/>
    
    </body>
    </html>

  • 相关阅读:
    win7下安装Linux实现双系统全攻略
    Dreamweaver_CS6安装与破解,手把手教程
    windows Server 2008各版本有何区别?
    如何查看路由器中的pppoe拨号密码?
    xp远程桌面连接最大用户数怎么设置?
    网站的盈利模式
    linux 下安装mysql-5.7.16
    GNS3连接虚拟机
    cain使用教程
    数据中心网络架构的问题与演进 — CLOS 网络与 Fat-Tree、Spine-Leaf 架构
  • 原文地址:https://www.cnblogs.com/liuxinls/p/3080795.html
Copyright © 2011-2022 走看看