简体   繁体   English

Google Map API:使用多种运输方式进行运输

[英]Google Map API : Route with more than one transport mode

I have a requirement in Google Map. 我对Google Map有要求。 I have Start and End Point. 我有起点和终点。 In between them, there are few waypoints. 在它们之间,几乎没有航路点。 I have to connect start and end point through the waypoints. 我必须通过航路点连接起点和终点。 This is feasible with google map api and i have done this. 这与谷歌地图API是可行的,我已经做到了。 But in one case, i have to draw rail route, that is, two waypoints will be connected by rail route. 但在一种情况下,我必须绘制铁路路线,即两个路线点将通过铁路路线连接。 So, i have a have route consisting of car route and rail route. 所以,我有一个由汽车路线和铁路路线组成的路线。

Sample: Consider A, B, C and D are the places. 示例:考虑A,B,C和D是地点。

A - Start Point, B- WayPoint 1, C - Waypoint 2, D - End Point A-起点,B-航点1,C-航点2,D-终点

A to B - Car route A到B-汽车路线

B to C - Rail route B到C-铁路路线

C to D - Car route C到D-汽车路线

How am i supposed to do this.?? 我应该怎么做?

Please guide me.!! 请指导我!!

I hope this example used for you And must be register YOUR_API_KEY also change your location latitude and longitude flightPlanCoordinates javascript variable value 希望此示例供您使用, 并且必须注册YOUR_API_KEY还要更改您的位置的经纬度flightPlanCoordinates javascript变量值

https://developers.google.com/maps/documentation/javascript/examples/polyline-simple?authuser=2 https://developers.google.com/maps/documentation/javascript/examples/polyline-simple?authuser=2

   <!DOCTYPE html>
    <html>
      <head>
        <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
        <meta charset="utf-8">
        <title>Simple Polylines</title>
        <style>
          html, body {
            height: 100%;
            margin: 0;
            padding: 0;
          }
          #map {
            height: 100%;
          }
        </style>
      </head>
      <body>
        <div id="map"></div>
        <script>

          // This example creates a 2-pixel-wide red polyline showing the path of William
          // Kingsford Smith's first trans-Pacific flight between Oakland, CA, and
          // Brisbane, Australia.

          function initMap() {
            var map = new google.maps.Map(document.getElementById('map'), {
              zoom: 3,
              center: {lat: 0, lng: -180},
              mapTypeId: google.maps.MapTypeId.TERRAIN
            });

            var flightPlanCoordinates = [
              {lat: 37.772, lng: -122.214},
              {lat: 21.291, lng: -157.821},
              {lat: -18.142, lng: 178.431},
              {lat: -27.467, lng: 153.027}
            ];
            var flightPath = new google.maps.Polyline({
              path: flightPlanCoordinates,
              geodesic: true,
              strokeColor: '#FF0000',
              strokeOpacity: 1.0,
              strokeWeight: 2
            });

            flightPath.setMap(map);
          }
        </script>
        <script async defer
        src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&callback=initMap">
        </script>
      </body>
    </html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM