Bike Maps

Selectively Disable WordPress Canonical URL and Redirect

Recently I wanted to change the way Ride Free Bike Maps accesses the individual routes. The way I had set up the app worked with query strings for access. That made for an ugly url and it wasn’t something the Google Bots would pay attention to. I tried to override their default behavior in the Google Webmasters page but it didn’t work. I had run across a snippets about writing url redirects using .htaccess. I never really cared too much until recently because I’m lacking on inspiration for more updates to add. I started with an .htaccess tutorial. There are a lot of them out there and they all produce the same end result so I won’t bother digging up the link. Basically the idea is to redirect the the users request url to a script. The script then dissects the url or gets a query string from the redirect and outputs the page you want. Sounds straight forward right?

Well with WordPress it isn’t. The problem stems from WordPress’ canonical urls. The canonical urls exist to redirect users and search engines from alternate ways of accessing the content to the preferred url. For the vas majority of WordPress sites this is the way to go. The alternate access points for the content are query strings which are ugly and bad for SEO. However, if you are running an app on your site which generates dynamic content then you will need to at least partially disable this feature. The first piece of the puzzle is to disable the automatic redirects when you access a non-canonical url. This is the most obvious part of the problem. I found a quick and easy solution from Mark Jaquith summarized on mydigitallife.com. Basically all you have to do is write (copy/paste) a simple plugin that disables the canonical redirect. Since I only need to disable the redirect on the route pages I made a modification with a fancy if statement:

/* Plugin Name: Disable Specific Canonical URL Redirection Description: Disables the "Canonical URL Redirect" features of WordPress 2.3 and above on specific URLs. Version: 1.0 Author: Ian Harper Author URI: http://ianbharper.com/ */ function map_page () { include(TEMPLATEPATH . '/page.php'); exit; } $routesResult = strchr($_SERVER['REQUEST_URI'],"/url_fragment/"); if ($routesResult) { remove_filter('template_redirect', 'redirect_canonical'); remove_action('wp_head', 'rel_canonical'); $_SERVER['REQUEST_URI'] = "/script_location"; } ?>

To use this plugin you need to replace url_fragment with a part of the url that you want to disable the redirect on. For my site route urls are formatted as /route/xx where xx is the route id. the script_location is the page that the url would redirect to. This is necessary because WordPress determines what page you are on by the $_SERVER[‘REQUEST_URI’] variable. Without this a 404 page is displayed no matter how much you curse at your monitor. To use this plugin all you have to do is pase it into your favorite text editor and upload it to your plugin directory on your site. The action from this script comes from the remove_filter and remove_action functions. The first stops the automatic redirect of the browser and the second removes the meta element in the head section. I learned about the meta tag by digging through the html source. Not many people worry about this problem so finding the solution was tough but PixelPunk had a solution.

The last thing I had to fix had to do with the way my Facebook plugin wrote the url for the page. I’m using the Simple Facebook Connect plugin which handles all the Facebook integration of my site. I was concerned with the like and share modules of the plugin. They use the WordPress get_permalink() function to determine the url to like/share. I replaced that with an if statement like the one above which changes the the link to the $_SERVER[‘REDIRECT_URL’] variable. This gives the desired url for the page. To edit the plugins use your favorite text editor.

Leave a comment

Bikehugger Demonstrates Google Bike Maps

I found this while musing about Google’s bike maps. The video is shot by bikehugger. It is a simple demonstration of Google’s bike maps. I was looking for way to improve my bike mapsweb app. When I found the video.

It isn’t super special but it does show how and why users should report problems to Google when they encounter problems using the bike maps.

Leave a comment

Google Bike Maps Video

I was doing a bit of reminiscing today about my journey into the internet beyond a passive consumer. Specifically I remembered the build-up to Google’s release of their bike maps. I went hunting for the video to clear the cobwebs a bit.

The bike maps video isn’t as good as some of their others, especialy the chrome speed test! I like it though because the addition of bike maps was huge for me.

My web app at ridefreebikemaps.com/map-creator got a huge boost in functionality from the update. Along with the benefits of having bike maps came several drawbacks as well: printing, way-point limits, map search, etc. It is the nature of things I suppose.

Well today’s closing is inspired by the El Nino rain: Now is a good time to do all those boring projects before the sun comes out again!

Leave a comment

Moving Forward?

So over the past week I’ve rolled out some great improvements to HTTP://WWW.ridefreebikemaps.com. I’ve added a way for users to add routes to the database; I made a short script to display those routes with their name and description in a way that Google can index; and I wrote in an option which lets users create routes outside of the USA. Awesome!

I’m well on my way to creating an honest to god web 2.0 bike maps app. Every day I learn new ways to integrate my app with the existing web 2.0 apps. Everything I learn inspires me to create better features for the app itself. I think my next big project is going to be adding author pages to the site. Here’s some of the ideas I’ve been thinking about:

  • Author Pages
  • Achievement Badges (x number of routes, long route, short route…)
  • Share routes with facebook upon creation.
  • Combine ‘Members Only’ and regular map creator.
  • Image/description previews of routes.
  • Browse routes via an interactive map (wow!)

On top of all that I’ve got to increase the traffic to my site. As it stands I get a good trickle from http://www.crazyguyonabike.com but I have to update the ‘time stamp’ on my link to keep it going. My roommate keeps telling me to start working some SEO magic but I don’t know where to begin. Eh I think I’ll just cross my fingers and hope somebody starts passing some serious stumbleupon/del.ici.ous/digg/facebook love on the site.

Posted via email from Ian’s Posterous

Leave a comment

Just uploaded an update to my Map Creator

So a couple weeks ago Google announced that they added a ‘bike there’ option to Google Maps. The next day they added the same thing to their API so web developers could use the directions in their apps. I was super thrilled when I heard the news and got to work as soon as I could on adding the directions to my app. It took me so long to make the switch because Google added the new directions to the V3 of the Google Maps API and my app was written in V2. 

V3 is technically still in Google Labs which means it’s in their version of a beta. I didn’t really figure that out until I had started making the switch. In hindsight I think I should have been more cautious but I felt that I had to make the transition to keep the pace. As I noted on the site the improvements are worth having, even if some gnarly bugs crawl out of the system.

 

I also took the time to make a bunch of improvements on the interface of the app. I think I made the whole thing a lot more streamlined and easier to use. Time will tell with that I suppose.

Posted via email from Ian’s Posterous

Leave a comment

Big day for bike maps!

Today Google officially announced the addition of a ‘bike there’ option for getting directions in Google Maps. This story has been covered by a few other blogs: 

For those of you who haven’t heard or want the teal deer version here it is!
  • This is fscking amazing!
  • Google considers information about terrain, roads, bike paths, and traffic when creating bike maps. 
  • The algorithm actually calculates the energy to pedal up hills and finds the easiest route. 
  • Google has also added a new layer to their maps which shows all the bike lanes, bike trails, and preferred streets for cycling on. 
  • If you ride bikes be happy!
  • I’m super into this sort of thing.

Some cool quotes:

 

Well now that the good news is out, I can lift the curtain and explain the many factors and variables that we’ve had to take into account to put this whole feature together:

  • Bike trails: Our maps contain over twelve thousand of miles of biking trails. First, we had to figure out where trails are, so we worked with the Rails-to-Trails Conservancy to get much of our trail data. Once we had trails mapped out, the next task was to incorporate them into our routing algorithm. The algorithm is weighted to strongly prefer routing on these trails rather than roads open to automobile traffic, so your directions will try to put you onto a trail as long as it won’t take you totally out of your way. On our bicycling layer (found under the ‘More’ button), these trails show up in dark green.

  • Bike lanes: For more than 150 cities in the US, we know which streets have dedicated bicycle lanes. These are also prioritized when coming up with a routing suggestion. On the bicycling layer, you’ll see these roads indicated in bright green.

  • Recommended routes: For many cities we also provide information on streets that have been designated as good for cyclists, so we them into account in our algorithm. These roads are indicated with dashed green lines on our bicycling layer.

  • Uphill slopes: l don’t know anyone who enjoys biking up a hill, especially when you’re trying to get somewhere you need to be. Going uphill is worse than simply being much slower; it’s also exhausting and can take a toll on the rest of your ride. Our biking directions are based on a physical model of the amount of power your body has to exert given the slope of the road you’re biking on. Assuming typical values for mass and for wind resistance, we compute the effort you’ll require and the speed you’ll achieve while going uphill. We take this speed into account when determining the time estimate for your journey, and we also try hard to avoid routes that will require an unreasonable degree of exertion. Sometimes the model will determine that it’s far more efficient to make you ride several extra blocks than to have to deal with a massive hill. My teammates in San Francisco were relieved to see that this does indeed work!

  • Downhill slopes: Many cyclists will tell you that going downhill is annoying for a different reason: you may have to ride your brakes all the way down. All else equal, we try to avoid routes that require a lot of braking. Of course, in some cities, including my hometown of Seattle, this isn’t always possible! And if you feel like you need a big workout and want to climb some hills, or if you just love that wind-in-your-hair feeling of a long downhill (you better be wearing a helmet and staying safe!), you can always turn on theterrain layer to check out the hilliness of an area for yourself.

  • Busy roads: Cyclists often tend to prefer to stay off of fast roads, and not even cross them unless it’s necessary. This is roughly the inverse of driving directions, where you want to stay on arterials and freeways, so we had to rework a lot of those fundamental calculations when coming up with our biking directions algorithm.

  • Busy intersections: We try to avoid making you cross busy streets with a lot of car traffic and long wait times.

 

When we launched Directions in Maps API v3 last year we asked “Where will you go from here?”. You may have asked the same question of us, and today we’re pleased to be taking another step forward with several new Maps API v3 Directions features.

  • Avoid highways and tolls. If you prefer to take the road less traveled you can now generate routes thatavoid highways. Similarly, if you find yourself a little short of loose change, you can avoid tolls.

 

  • Route optimization. Have many places to go but no preference as to the order you visit them in? We can now reorder the waypoints of your route to minimize the distance and time you must travel. Very useful for traveling salesman I hear.

     

  • Bicycling directions. Prefer your vehicles of the two wheeled human powered variety? In conjunction with the launch of Bicycling directions in Google Maps you can now also request directions in Maps API v3 that are tailored to your Penny-farthing.

 

Posted via email from Ian’s Posterous

Leave a comment

Finally another update to my map creator!

For at least the past week I’ve been compulsively working on upgrading my map creator at Ride Free Bike Maps. The upgrade that I published isn’t an upgrade to the main app, per se. It’s a demonstration of where the app is headed beautifully displayed in a parallel instance of the software. Essentially I created a new instance of the app and gave it special powers to load a single, hard coded route, from a database. A database which includes a grand total of TWO ROUTES! You can check out the upgrade to the bike map creator here and the post that announced it here

All kidding aside, I did spend a lot of time on this. Mostly because this is beyond anything I’ve ever done before. Databases, CGI, and AJAX are things I had to learn to get this working. hopefully I’ll be able to easily expand this further by creating some kind of public access to the route creation process.

 

I’m super proud of myself for getting this working. Go me!

Posted via email from Ian’s Posterous

Leave a comment

Update teaser

So for the past three days I’ve been working on upgrading the UI of the map Creator app. The goal is to make it more intuitive and streamlined. I’ve got the bulk of the app done, all that is left is some fiddly CSS changes. Hopefully I’ll get those taken care of tomorrow. If I don’t the update will go live regardless because I’m going south for the weekend.
Without fully detailing the changes here is what I’ve been working on:

  • Plot mode is now route.
  • Reroute button.
  • Panel mode is now Divide.
  • Print mode is the same but now it shows all of your pages at once so you only have to print it once!

I will be writing a more detailed post when the changes go live so stay tuned!

Posted via email from Ian’s posterous

Leave a comment

Change of Direction!

Initially I had planned for this blog to strictly be a promotional tool for my other blog/webapp www.ridefreebikemaps.com. After making this blog and failing to update it all I decided to abandon that idea and turn this into a personal blog.

The initial idea was to make all kinds of posts optimized for the keywods ‘bike maps.’ Now I’m just gonna post about the things that I’m into, cycling, beer, tech, and whatever adventures I get into. I’ll be doing a lot of posting using posterous so if you prefer you can get the same quality content there!

So don’t expect too much from this blog. It is going to be my ‘fun only’ blog. If you are down to look at the random pics I take with my phone and various rants and ramblings great! Subscribe to the rss!

Until next time!

-Ian

Leave a comment

Google Bike Maps!

Well they havent come about yet but they will soon! Check out the Google maps trike in action:

Amazing! I can’t wait for Google to unveil their ‘bike there’ option. It is rumored that they will be doing it soon, what ever that means. I am especially excited because I have written a web app that formats Google maps to use in a bike map holder. My goal it to take free information from Google and using web 2.0 magic create some really useful tools. When they finally do release ‘bike there’ my web app will be able to chart the best route for cyclists.

As it stands my software is best when used with other bike maps.  I add more functionality to it all the time so check it out and leave me a comment!

Ride Free Bike Maps

Leave a comment