New version of Routes WordPress plugin

Author: Jennifer Hodgdon
Date Written: 30 January, 2019
Type: News/Blog
Subject: WordPress

Back in 2010, I created a WordPress plugin called Routes and released it to the public on this web site. It allows you to add geographical information to WordPress posts and pages, and display them on a map. I created it for a travel blog, because I couldn't find a Drupal or WordPress module/plugin with similar functionality -- we wanted not to show not just one or a few geographical points on each blog post, but the details of our bike touring routes.

Today I just released version 3.0 of Routes, with some big changes. The previous versions of Routes had used Google Maps; this one instead uses the open-source Leaflet JavaScript library to display Open Street Map maps. A few features were lost (address lookup, map type options, driving directions, and street view), but there's a new feature that's pretty cool: interactive elevation charts.

Also, this version requires fewer modifications of your theme in order to work. If you're updating from the older Routes to this one, you'll need to remove the call to

routes_do_map_js()

in the footer file, but everything else will probably work fine.

As a note, I considered (for my own site, anyway) migrating to Drupal and using its existing ecosystem of geographical modules, but I eventually decided against it. Here's why:

  • The main Drupal module for storing geographical information is Geofield, but it wouldn't work at all for my purposes, because it does not support storing elevation, text tags, city, or state information along with the latitude and longitude.
  • You can mix Geofield (apparently) with the Address Field module to add address information, but that still doesn't support text tags. I'm not sure the combination works well with multiple points either or maintains the correlation between the individual items in each field.
  • Neither Geofield nor Address Field supports input of an entire route containing hundreds of points very well, with mixed map and textual input, the way the Routes plugin does.
  • I also wasn't convinced that the output options were great. I probably would have ended up writing some of my own code for putting the information out on a map.

Given all of that, rewriting the Routes plugin to use Leaflet instead of Google Maps JavaScript calls, but keeping the existing editing and database infrastructure, seemed like the best option. It took me a few iterations, but I'm pretty happy with the results!