GDirections 25 element limit

There’s an undocumented feature in the Google Maps API when retrieve driving direction wherein any GDirections request with more than 25 elements returns an error with code G_GEO_BAD_REQUEST (400). This isn’t particularly helpful but I found the answer in the Google Maps forums somewhere. So the trick is to partition your array of waypoints into 25 part segments. Using Prototype 1.5 this is really simple using the inGroupsOf method, however using earlier Prototype versions is a little more tricky. I’m including a function that can do it with either.

function doDirections(elements) {
  var mapLimit = 25;
  elements = $A(elements);
  var groups = null;
  if('inGroupsOf' in elements) {
    groups = elements.inGroupsOf(mapLimit);
  } else {
    groups = [];
    var tempGroup = [];
    elements.each(function(point, index) {
      if(index == mapLimit) {
        groups.push(tempGroup);
        tempGroup = [];
      }
      tempGroup.push(point);
    }
  }

  groups.each(function(i) {
    var direction = new GDirections();
    //Insert your options for directions objects here.
    direction.loadFromWaypoints(i);
  }
}

The dodgy AFL website – part 1

For a long time I have had problems with the AFL website, over the years it has progressively been getting worse and worse. First of all they did a web distribution deal with Bigpond a few years ago who then proceeded to put a completely non-functional 55px high bar on not only afl.com.au but also on each of the club websites. First of all, I’m not convinced this is in the best interest of the AFL, nor the clubs. Why is some random brand plastered in some of the most important real-estate on the page, and secondly why is the AFL diminishing it’s brand. Presumably, the AFL believes that selling the Internet distribution of it’s games is a better deal than dealing with this itself.

Sure, the Internet is tricky, making 24 hours of video available every week to x number of subscribers isn’t going to be an easy thing to do, (a task that Bigpond should have the expertise to pull off.) However the benefits of doing it could be awesome, not only as a money maker for the AFL but also to provide a great experience for the club members and AFL supporters in general. Imagine being able to grab any of the highlights packages (with advertising) for free, or a club Internet membership level where I can watch all 22 home and away games of my club.

This is a case of the AFL being stuck in the past as far as distribution of it’s assets goes, and really isn’t buying into the future of the game. The Internet is the way forward and could be used as an amazing marketing tool in the push for AFL to move across the globe, instead it is being used to push people to subscribe to Telstra’s Bigpond service. This is definitely something the AFL should have considered more carefully, and possibly invested in it’s future rather than it’s bottom line. It is definitely conceivable that the $20 million dollars it made in 2007 might look very small in 2011.

Control.Modal.Dialog – a lightweight javascript modal dialog library

Recently we realised that we were in need of a modal form/dialog. Sure there is a javascript “dialog” function however it is completely useless in IE7 and what’s more it’s not really ideal in other browsers. Most of our work is based on Prototype/Scriptaculous and we have used Control.Modal in other projects so I went about writing a small layer that can sit on top of it to provide an easy to use modal dialog. Control.Modal.Dialog was born.

At the same time, I’ve spent about 3 minutes setting up Xebidy’s Code Library, we are planning on releasing more and more of the code we are writing internally to the world under Open Source licenses and hopefully Bootstrap will be one of those. Sadly, other things tend to get in the road, like clients.

Update 4/06/2008: We have released a new much better version of this. It still lives at the same place.