Mystery Incorporated


Programming, photography, news, culture, and cartoons

home | rss | atom

Add to Google

CaBi Mapper: Bikeshare Availability & Activity


February 2nd, 2012 [programming]

Here’s my application for discovering Capital Bikeshare (CaBi) locations, and the availability of bikes and empty docks. I was inspired to build CaBi Mapper after the Bike Shops and Beyond project, which was populated with coordinates for a variety of businesses and services, including CaBi locations.

The data came from Capital Bikeshare‘s bikeStations.xml file, which is constantly updated as bikes are checked out and returned. It includes latitude and longitude, so mapping is easy. PHP lets you read in the entire XML file with a single function, simplexml_load_file. I used the Google Maps JavaScript API v3 to draw the map (with help from OpenStreetMap).

Once the data is available, the rest of the project is designing the user interface. I chose to go with pie charts to show the ratio of available bikes to empty dock slots. Red (matching the color of the bicycles) is used to represent available bikes, and dark blue represents free spaces. Hovering over a marker displays the exact number of bikes and slots, as well as the location. Clicking on the marker will zoom in and pan to the center, and display an information window with the location, availability statistics, and the date and time that a change was last reported, meaning the last time a bike was either taken or returned.

The “activity” button lets you explore a different set of data for the same stations. This time the pie charts reflect how long it’s been since each station has seen any activity. The ratios are normalized to span the maximum and minimum update times for the stations currently displayed in your view port. You can recalculate the distribution after you pan or zoom the map. The more-yellow stations had check-ins or -outs more recently than the more-black stations.

You can hit the “A” button to toggle between activity and age. “Age” mode uses green-and-brown charts to show the relative age of each station, based on when it was installed.

Note the data is static. In this first version, to get new CaBi stats you have to refresh your browser.

The CaBi Mapper app works in your browser, and scales for desktop or mobile devices. If your browser supports geolocation, you’ll see a “locate me” button which will zoom the map to your location.

The app is at mvjantzen.com/cabi. Your comments and suggestions are welcome.

2 Responses to “CaBi Mapper: Bikeshare Availability & Activity”

  • Will Handsfield says:

    I enjoyed your map very much. A while back, I mapped all the public equestrian sculptures in the District and the monumental part of Arlington. I never did do this bike ride, but looking at your other maps, perhaps you could find better use for the data:

    http://maps.google.com/maps/ms?ie=UTF&msa=0&msid=
    203600214166941309653.0004952e14d5548f686ad

  • Christiann says:

    This is pretty cool! It actually works on my low-tech BlackBerry, which is nice because I haven’t been able to load Spotcycle’s BlackBerry app, and according to the reviews, it’s not very full-featured anyway. And CaBi’s web-based map is hopeless on mobile. Have you considered making this open source? Thanks!

  • Leave a reply



Site by M.V. Jantzen
mvs202 "at" gmail.com
twitter.com/mvs202