2016-06-14 89 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的问题) –