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

Track actual bus locations #30

Open
j-ro opened this issue Feb 27, 2013 · 5 comments
Open

Track actual bus locations #30

j-ro opened this issue Feb 27, 2013 · 5 comments

Comments

@j-ro
Copy link
Owner

j-ro commented Feb 27, 2013

Not sure if WMATA publishes this data, and would involve different pin styles in the mapkit plugin, but would be cool if we could track actual buses on the roads.

@ITSoFRISCHial
Copy link

They do in fact! An example URL request would look like this:
http://api.wmata.com/Bus.svc/json/jBusPositions?routeId=10A&includingVariations=true&lat=0&lon=0&radius=0&api_key={key}

The response body looks like this:
{
"BusPositions": [{
"DateTime": "2013-03-01T15:37:04",
"Deviation": "-2.07",
"DirectionNum": "1",
"DirectionText": "SOUTH",
"Lat": 38.792793,
"Lon": -77.049606,
"RouteID": "10A",
"TripEndTime": "2013-03-01T15:35:00",
"TripHeadsign": "HUNTING POINT",
"TripID": "20383_11",
"TripStartTime": "2013-03-01T14:53:00",
"VehicleID": "2173"
}]
}

@j-ro
Copy link
Owner Author

j-ro commented Mar 1, 2013

Very cool! Now I have to figure out how to extend the Cordova MapKit plugin to do other types of annotations besides pins (like, say, a little bus icon) and we'd be in business!

@ITSoFRISCHial
Copy link

Never used Cordova before but when I get a chance I'll dive into your code to see how I can help.

@j-ro
Copy link
Owner Author

j-ro commented Mar 1, 2013

Cool! I'm assuming what you'll want to extend is this file:

https://github.com/j-ro/WheresTheBusDC/blob/master/WheresTheBusDC/Plugins/MapKit.m

And maybe MapKit.h, too. Objective-C is not my strong suit...

But basically what we'd need is a function similar to the one that's there to create pins, which allows me to build a pin array like this:

pins.push(
            {
                lat: [latitude of my pin],
                lon: [latitude of my pin],
                title: [title of my pin when tapped],
                pinColor: "green", [<-- maybe this is replaced by a link to an image? or some variable that refers to an objective-C image that we assign, like a little bus icon?]
                selected: false, [<-- choose whether or not the pin drops and immediately selects, I always say false]
                index: i [<-- I don't use this...]
            }
        );

And then drop the pins on the map like this:

window.plugins.mapKit.addMapPins(pins);

And clear them like this:

window.plugins.mapKit.clearMapPins();

So, if we have a version that was addMapIcons and clearMapIcons that dealt with these icons, that would do it I think!

@j-ro
Copy link
Owner Author

j-ro commented Mar 1, 2013

The above code is all javascript, BTW -- probably obvious, but worth clarifying. So the plugin takes those javascript functions/data and turns them into objective-C somehow and displays them on the native map.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants