As mentioned in my last post, the GeoPortal Project recently had a monster update (and has had several more git pushes since then - I never do anything right the first 12 times). I then spent the better part of a day and a half porting over Mecklenburg’s GeoPortal, which uses the Google Maps API.
The Google Maps API v3.9 kicked off at Google I/O, and among the really awesome changes was the addition of Transit to the routing options. As the response to my request for a GTFS file from a local transit authority could be best summarized as get bent 1, I was doubly-drooling over this. Now when you select an address it populates a From box in a routing tab/accordion (never sure what to call that). Then if you populate the To box or click on a someplace to populate it, a-routing you go.
This is really easy to do - you just tack a mode on to your routing options. It will automagically add the route to the map, directions, click-links between the two…everything. Here is a JSFiddle of the code involved, including draggable routes. Easy peasy.
Note you can always grab the latest Mecklenburg GeoPortal code on Github.
1 If you ever get an actual and proper get bent from a public servant, you were probably talking to me. What you will get instead is something more like: In order to even consider sharing your public data with you we will need to spend months working out a Service Level Agreement (SLA), Memorandum of Understanding (MOU), and any other acronym me might make up just For You (FU). It goes without saying our written agreements will specify that the only person you can show your public data to is your dog. That’s what I got when I made a request for a GTFS zip file (bunch of text files with route and rate information) to a local transit authority, and it means get bent. Unfortunately this happens a lot in North Carolina. I would have made my own GTFS file and put it on Github for spite, but my low-level need (I really just wanted to screw around with OpenTripPlanner) and general aversion to work trumped my irritation.