List of bus stops from Google Maps
Asked Answered
C

5

9

I am trying to build web app where you input your address and it will give you list of bus stops in your area. I want to use Google Maps for this, but i can't find the way to use them for this. Is there any way to get list of points on maps in, lets say, JSON or XML format? I tried Google Maps Places API, but it didn't work this way. Only thing i found is this example - http://gmaps-samples-v3.googlecode.com/svn/trunk/localsearch/places.html but thats not what i need.

So, anyone knows?

Charil answered 21/8, 2011 at 15:15 Comment(0)
H
1

You could use Google Fusion Tables for this. You would have to enter the data yourself though, unless someone else already have entered it. Google maps API supports Google Fusion Tables.

Hakluyt answered 21/8, 2011 at 18:57 Comment(5)
Well this is opposite to what I need. This is data -> points on map, but I need points on gmap -> data :) But thanks for tip, dunno about this project.Charil
Sounded like you needed data ("Is there any way to get list of points on maps in, lets say, JSON or XML format?"). If you already have the data and need to export it to json or xml that would be kind of straightforward? Or Maybe I'm just too tired to read :)Hakluyt
Ok, maybe I wrote it wrong. I need to get data FROM gmap. I only have address and I need to get list of bus stops near that addressCharil
You can't get a list of bus stops just by entering the address from Google Maps API. That data isn't there by default. The best thing would be to look at Google Fusion Tables, open data (google.com/search?q=open+data), or crawl for information.Hakluyt
As described, support.google.com/fusiontables/answer/… "Google Fusion Tables" may be no longer available.Tertius
I
5

The Google Places API does have stop information on there but you need to form your query very specifically to make it work.

The key is using the nearby search with rankby=distance and radius= and types=bus_station

The default rankby prominence rarely shows bus stations.

Sample query:

https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=49.89458,-97.14137&sensor=true&key=your_key&rankby=distance&types=bus_station

Interjection answered 20/12, 2012 at 18:49 Comment(2)
this is only for bus STATIONS I think, not bus stops. Not entirely sure about that thoughNewfangled
EDIT: Nope, only bus stations. Not the bus stops. Much better than nothing thoughNewfangled
C
3

I think it can help you

<script>
  // This example requires the Places library. Include the libraries=places
  // parameter when you first load the API. For example:
  // <script src="https://maps.googleapis.com/maps/api/js?key=YOUR_API_KEY&libraries=places">

  var map;
  var infowindow;

  function initMap() {
    var pyrmont = {lat: 38.06908229560463,  lng: 46.31730562744135};

    map = new google.maps.Map(document.getElementById('map'), {
      center: pyrmont,
      zoom: 15
    });

    infowindow = new google.maps.InfoWindow();
    var service = new google.maps.places.PlacesService(map);
    service.nearbySearch({
      location: pyrmont,
      radius: 1000,
      types: ['bus_station','transit_station']

    }, callback);
  }

  function callback(results, status) {
    if (status === google.maps.places.PlacesServiceStatus.OK) {
      for (var i = 0; i < results.length; i++) {
        createMarker(results[i]);
      }
    }
  }

  function createMarker(place) {
    var placeLoc = place.geometry.location;
    var marker = new google.maps.Marker({
      map: map,
      position: place.geometry.location
    });

    google.maps.event.addListener(marker, 'click', function() {
      infowindow.setContent(place.name);
      infowindow.open(map, this);
    });
  }
</script>
Cloraclorinda answered 24/9, 2016 at 10:14 Comment(0)
M
3

Ali Seify's answer is correct except that the API document states that only the first element in the types parameter will be used by the API and the transit_station type is the correct type for bus stop.

Also, in order to get the nearest bus stop, suggest to use parameter rankBy: google.maps.places.RankBy.DISTANCE and radius parameter cannot be used in this case.

service.nearbySearch({
  location: pyrmont,
  rankBy: google.maps.places.RankBy.DISTANCE,
  types: ['transit_station']

}, callback);
Mathis answered 30/11, 2019 at 14:41 Comment(0)
C
2

This is not a service that Google provides. They surely have all of the stuff you need on record, but they do all of their calculations internally.

One option (which might be a bit difficult) is to mine public transportation schedules for their bus stop locations. It might be an option if you have a small region (ie. a city) that your web app is to support. It's risky because if the pages change then you'll have to reconfigure the data mining application, but you'd still have the same problem trying to mine the data from Google (or somewhere else) - if you could find a way to get a bus stop list with locations and built your app around it, it could change at any time and break your application.

Construct answered 21/8, 2011 at 15:30 Comment(1)
I dont need schedules, just bus stops with their lat&lng. I have another app for schedules, but i dont want to mine all bus stops manualy :) But you are right with building app around mining softCharil
H
1

You could use Google Fusion Tables for this. You would have to enter the data yourself though, unless someone else already have entered it. Google maps API supports Google Fusion Tables.

Hakluyt answered 21/8, 2011 at 18:57 Comment(5)
Well this is opposite to what I need. This is data -> points on map, but I need points on gmap -> data :) But thanks for tip, dunno about this project.Charil
Sounded like you needed data ("Is there any way to get list of points on maps in, lets say, JSON or XML format?"). If you already have the data and need to export it to json or xml that would be kind of straightforward? Or Maybe I'm just too tired to read :)Hakluyt
Ok, maybe I wrote it wrong. I need to get data FROM gmap. I only have address and I need to get list of bus stops near that addressCharil
You can't get a list of bus stops just by entering the address from Google Maps API. That data isn't there by default. The best thing would be to look at Google Fusion Tables, open data (google.com/search?q=open+data), or crawl for information.Hakluyt
As described, support.google.com/fusiontables/answer/… "Google Fusion Tables" may be no longer available.Tertius

© 2022 - 2024 — McMap. All rights reserved.