Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Miami Beach trolleys #8

Open
qtrandev opened this issue Apr 28, 2015 · 0 comments
Open

Get Miami Beach trolleys #8

qtrandev opened this issue Apr 28, 2015 · 0 comments
Assignees

Comments

@qtrandev
Copy link
Member

Code committed here shows how to get the data: qtrandev/LeafletTransit#11

Online map of Miami Beach trolleys is at:
http://app.tsomobile.com/publictransportation/driverroute.htm?tkn=825894C5-2B5F-402D-A055-88F2297AF99A

Sample direct links for live trolley locations (it sends 2 queries):
http://rest.tsoapi.com//MappingController/GetUnitFromRouteAntibunching?tkn=825894C5-2B5F-402D-A055-88F2297AF99A&geofencesid=38836&lan=en
http://rest.tsoapi.com//MappingController/GetUnitFromRouteAntibunching?tkn=825894C5-2B5F-402D-A055-88F2297AF99A&geofencesid=40756&lan=en

Code to get live trolley locations (source):

function addMiamiBeachTrolleys() {
  var api = 'http://rest.tsoapi.com/';
  var controller = 'MappingController';
  var methodName = 'GetUnitFromRouteAntibunching';

  var data = [];
  var miamibeachtkn = '825894C5-2B5F-402D-A055-88F2297AF99A';
  data[0] = { tkn: miamibeachtkn, geofencesid: '38836', lan: 'en' };
  data[1] = { tkn: miamibeachtkn, geofencesid: '40756', lan: 'en' };

  sendTSOTrolleyRequest(api, controller, methodName, data[0], handleMiamiBeachTrolleyCallback);
  sendTSOTrolleyRequest(api, controller, methodName, data[1], handleMiamiBeachTrolleyCallback);
}

function sendTSOTrolleyRequest(api, controller, methodName, data, callback) {
  $.ajax({
    url: api + "/" + controller + "/" + methodName,
    data: data,
    type: "POST",
    contentType: "application/javascript",
    dataType: "jsonp",
    success: function (data, textStatus) {
        //console.log(data);
        callback(data);
    },
    error: function (xhr, status, errorThrown) {
        console.log(xhr.statusText);
    }
  });
}

Direct link to routes and points:
http://rest.tsoapi.com//Routes/GetRouteFromToken?tkn=825894C5-2B5F-402D-A055-88F2297AF99A&routeId=-1

Code to get trolley routes and points (source):

var api = 'http://rest.tsoapi.com/';
var controller = 'Routes';
var methodName = 'GetRouteFromToken';

var data = { tkn: '825894C5-2B5F-402D-A055-88F2297AF99A', routeId: '-1'};

sendTSOTrolleyRequest(api, controller, methodName, data, handleTSORoutesCallback);

function sendTSOTrolleyRequest(api, controller, methodName, data, callback) {
  $.ajax({
    url: api + "/" + controller + "/" + methodName,
    data: data,
    type: "POST",
    contentType: "application/javascript",
    dataType: "jsonp",
    success: function (data, textStatus) {
        //console.log(data);
        callback(data);
    },
    error: function (xhr, status, errorThrown) {
        console.log(xhr.statusText);
    }
  });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants