2016-06-14 31 views
1

我在找做這樣的網站:WEBSITE GMAPS檢索谷歌地圖API的公交線路或地鐵的細節

目前我能找到解決500米一切一樣,如果它是一個公共汽車站或別的東西,但我無法檢索公交線路。

var mapControl = $scope.map.control.getGMap(); 
     service = new google.maps.places.PlacesService(mapControl); 
     var transitLayer = new google.maps.TransitLayer(); 
     transitLayer.setMap(mapControl); 
     var directionsService = new google.maps.DirectionsService(); 

     service.search(request, callback); 

     function callback(results, status) { 
      if (status == google.maps.places.PlacesServiceStatus.OK) { 
       $scope.placesTransit = []; 
       $scope.timeTotal = []; 
       angular.forEach(results, function(result, key) { 
        var timeTotal; 
        directionsService.route(
        { 
         origin: new google.maps.LatLng($scope.map.center.latitude, $scope.map.center.longitude), 
         destination: result.geometry.location, 
         travelMode: google.maps.DirectionsTravelMode.WALKING, 
         unitSystem: google.maps.UnitSystem.METRIC 
        }, function (response, status) 
        { 
         if (status == google.maps.DirectionsStatus.OK) 
         { 

          result.timeTotal = response.routes[0].legs[0].duration.text; 
          if (result.types[0] === "subway_station") { 
           result.typeTransport = "Métro"; 
          } 
          console.log(result); 
          $scope.placesTransit.push(result); 
         } 
        }); 
       }); 
      } 
     } 

,如果有人可以幫助我該怎麼做: 顯然,我可以檢索此page此信息,但沒有什麼用谷歌地圖API V3得到這個。任何想法 ?謝謝

回答

0

是的,Google有一個地方可以獲取有關公共交通的信息。

首先,你需要檢查是否支持您的城市:

然後,如果支持,你可以在這裏得到更多的信息:

以編程方式訪問它,你既可以下列API:

我會與第二個去。考慮到這一點,如果您正試圖檢查的公司已註冊,您將可以輕鬆訪問其所有公交路線(以及更多)。

如果公司不但是上市,這意味着他們的編碼,你在地圖上看到的路徑,你必須做好利用覆蓋相同:

希望它幫助!

+0

感謝您的時間,我會檢查這種方式! :) Transit Transit看起來很難使用! –

+0

如果您有其他麻煩,請記住重新發布! (在另一個xD的問題) –