Skip to content

Commit

Permalink
Update the JS api to reflect distance.
Browse files Browse the repository at this point in the history
  • Loading branch information
Sutto committed Nov 24, 2012
1 parent f133f35 commit b176a45
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion js-api/perth_transit-1.0-min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 8 additions & 6 deletions js-api/perth_transit-1.0.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
root: "http://api.perthtransit.com/",
};

var dataWithLocation = function(location) {
var dataWithLocation = function(location, distance) {
if(!location) {
return null;
} else {
var lat = location.lat || location.latitude;
var lng = location.lng || location.lon || location.longitude;
var near = "" + lat + "," + lng;
return {"near": near};
var options = {"near": near};
if(distance !== undefined) options['distance'] = distance;
return options;
}
};

Expand Down Expand Up @@ -65,16 +67,16 @@
return locationDeferred(function(location) { return PerthTransit.busStops(location); });
};

PerthTransit.trainStations = function(location) {
return this.get('train_stations', dataWithLocation(location));
PerthTransit.trainStations = function(location, distance) {
return this.get('train_stations', dataWithLocation(location, distance));
};

PerthTransit.trainStation = function(station) {
return this.get('train_stations/' + extractIdentifier(station));
};

PerthTransit.busStops = function(location) {
return this.get('bus_stops', dataWithLocation(location));
PerthTransit.busStops = function(location, distance) {
return this.get('bus_stops', dataWithLocation(location, distance));
};

PerthTransit.busStop = function(stop) {
Expand Down

0 comments on commit b176a45

Please sign in to comment.