TwittEarth

Wow, I like TwittEarth. I’m not big on the monster icons, but, hey, the experience is still very cool.

TwitterVision has a 3D live tweet map too, using Poly9’s (great studio in Quebec City) FreeEarth application.

I’d love to see a trip animated in FreeEarth. Perhaps a mashup with Dopplr? It would seem easily possible.

Comments (2)

Embedding a Google Maps street view widget on your site

Update - Turns out panoIds are only unique to a session, and so my example is broken and no longer useful. Unfortunate, really.

Let the fun begin! Street view support is baked into the latest (unofficial, 2.103) version of the Google Maps API. Check out Google Maps Mania and Mapperz for some good coverage and a couple examples. If you’re a developer, Mike Williams, as always, has dug through the code and produced some speculative documentation.

Street view support is essentially comprised of 3 classes: GStreetviewOverlay, which creates a tile layer overlay for areas having street views, GStreetviewClient, to look up panoramas by lat/lng, etc.., and GStreetviewPanorama, which inserts a flash movie into the DOM and manages points of view.

I can imagine plenty of applications for this (walking tours anyone? Can we make this work with GDirections?), but here’s a simple one for now - since a street view panorama is simply a flash movie initialized via flashvars, you can actually set up a panorama without a map, like so:

Getting your hands on the right parameters is rather cumbersome, so I’ve written up a quick little app that’ll permalink a view for you, similar to maps.google.com, plus give you some iframe code to embed. Check it out. (Disclaimer: You may encounter intermittent JavaScript errors on info windows in IE. Sadly, I can’t hack it because the bug is in code dynamically served by Google.)

A little heads up on how the example works, since I had to go off the radar a little: A view is defined by panorama id, yaw (rotation in degrees around vertical axis), pitch (rotation in degrees around horizontal axis), and zoom level. If you’ve got these parameters, you can set the view using streetviewclient.getPanoramaById and panorama.setLocationAndPOVFromServerResponse. The API has a routine to grab yaw, pitch, and zoom (getPOV), so that part’s easy, but there’s no routine to grab the current panorama id. It’s stored on an exposed object, though, so this little hack does the trick, at least until v2.104:

GStreetviewPanorama.prototype.getPanoid = function()
{
return this.I.zj;
}

Enjoy!

Comments (1)

A big wanderingken tracking map

In a previous post I described how to cobbled together a Telus Motorola iDen phone and mologogo in order to make a live tracker, pointing folks to the the map at the top of the right-hand column in this blog. (Haven’t seen it? Look there now.)

At the time I posted the map, I felt it rather small and uninformative, but no one complained. That is, until last week, when a friend (thanks, Jesse) proceeded to give me the gears over not being able to `see the larger context’ and not being able to switch to satellite mode.

As Jesse had just tapped into one of my own frustrations, I figured I’d better put in the time to make a more interesting map. So…, now, if you click on the tracking map, or follow this link, you can see a full-screen page showing my last reported location. You can also see the direction I was traveling at the time, my traveling speed, and altitude. Additionally, and this is the really cool bit, you can switch between google, yahoo, and microsoft virtual earth maps, enabled by mapstraction, a javascript library designed, and I quote, ‘to hide differences between different mapping APIs’. Mapstraction is currently in the very early stages, and does not attempt to handle polylines, but works very well for maps with simple markers. It is well-designed enough that I needed write only one map loading function, giving a map provider parameter as input.

Check it out!

Comments (1)

The essence of web 2.0

Ahh, web 2.0.

Means little to most of my friends, and means absolutely nothing to my parents. Intended to capture our current web boom, complete with it’s $1.6 billion rags to riches deals, personal broadcasting and networking pages (a la myspace), and wiki-driven content, it seems no one is really able to qualify what exactly it means. Tim O’Reilly’s assessment of ‘the web as platform’ is probably the most quoted, but the meat of his article consists of comparisons (web 2.0 is wikipedia and not Encyclopedia Britannica, Adsense and not Double Click, tagging and not taxonomy, etc). The authors of Wikipedia’s article suggest other phrases, such as ‘network of participation’, ‘perpetual beta’, and ‘the long tail’.

That’s all well and nice, of course, but we all know that web 2.0 really consists of pastel colours, boxes with rounded corners, fuzzy user profile images, and the phrase ‘cool new’. Or, as Bill Amend, Foxtrot comic artist, suggests, web 2.0 is essentially blank web pages:

Foxtrot web 2.0

All this talk has fueled my own creative web 2.0 juices, and so, with help from walter zorn’s considerable talents, I submit my own response to Bill’s comic: The web 2.0 essence.

Hint: draw some raindrops. Click here to erase them. Or, try a larger canvas.

Comments

Tracking wanderingken with Telus, an iDen, Mologogo, and Geonames

So, as one might expect given my propensity to hack around with google maps, I’m fascinated by the idea of GPS receivers inside cellular phones. Cell phones have a significant advantage over traditional GPS devices in that not only can they pinpoint your location, they can immediately send that information. Immediately upon receiving your location, a 3rd party (say, your cell provider, google maps, etc…) can return relevant location-based information. Very cool.

Nearly all cell phones now have forms of GPS capability built-in, as GPS is now required by the U.S. FCC for enhanced 911 services, although in many cases GPS capabilities area actually assisted GPS, estimated by proximity to cell towers and not retrieved via satellite. However, as discussed recently on NPR recently, and I’m sure many cell owners have discovered, cell users can’t necessarily get at the information. Privacy concerns are play a significant role in this, of course, though one also has to believe cell providers are protecting location information until they can figure out how to make money from it..

I discovered all this a year or so ago, with my Sanyo SCP-2300 — GPS enabled, and I could turn the GPS function on and off, but good luck getting the phone to spit out a latitude and longitude. 911 could find out where I was, though, as I discovered when I called to report dangerous roadkill on Alberta’s highway #2.

Anyway, it turns out Sprint / Nextel in the U.S. is bucking the trend, allowing access to GPS on Motorola iDen phones, which has prompted the fellows at Mologogo to write a little J2ME live tracking app which plots you (and your phone) on a google map, on your phone. As an added feature, you can specify a server URL to which to post this location when obtained (via HTTP GET), and even ask your phone to show you where your fellow mologogo-friends are. It’s also free.

Motorola iDen 850

In Canada, iDen phones are sold by Telus Mobility for their Mike network, and, it turns out, Telus also allows GPS access on these phones. So, when my recent move from Toronto to Edmonton provided an excuse to buy a new phone, I figured I’d try see if I could create a little live blog tracker here in Canada and hooked myself up with one of these fellows (an i850, as in the photo). It works! Wanderingken.com tracks my wanderings in real-time (provided I’ve got mologogo running and it’s sunny outside). If you’re watching at the right time, you’ll even see the marker move before your very eyes. My own little Where’s Tim.

Here’s how: You’ll need both a USB data cable (I haggled a free one from the cell store guys) and a Motorloa Java application loader. Good luck, though, on the application loader. Motorola has an application form here, but it’s rather restrictive. Or, you can try wade through this site (as I did, and ended up installing a 7-step something or other that did, actually, work). Complex as hell, and only necessary because both Sprint / Nextel and Telus see fit to disallow downloading J2ME application types via the mobile browser, something Bell Mobility, interestingly, does not restrict.

After that, you’ll need to create a little end-point url which saves latitudes and longitudes arriving as GET parameters into a server-side file, and specify this url in the mologogo preferences (on your phone). Then, map the latitude and longitude to a place name via geonames, sprinkle in a a little google maps code and an Ajax-based periodic updater, and ta-da, live tracker.

Comments (17)

Extending Prototype for Javascript Inheritance : Class.extend()

Many folks around the web are raving about Prototype, a Javascript library written by Sam Stephenson which features “a unique, easy-to-use toolkit for class-driven development and the nicest Ajax library around.” (I stole that line from the prototype site).

Prototype’s popularity is certainly due in part to it’s inclusion in current web darling Ruby on Rails, but that ought not to slag the package (or rails) one bit — I’ve used prototype a fair bit over at GeoBirds, and have become rather reliant on it. In many ways, it solves a ton of problems I didn’t realize I had. Heck, by simply shortening document.getElementById to $, prototype has saved me countless keystrokes, although one might rightly suggest I should have written myself a helper function earlier.

If you’re like me, however, you’re still rather troubled by prototype’s claim of “class-driven development” in Javascript. In fact, you’re probably a little fuzzy on the differences between object-oriented and prototype-based languages (hey, is that why they called it prototype?), and, if you’ve investigated them, you find approaches to enabling classical object-oriented development in Javascript rather unintuitive. (See here, here, and here, all good stuff, but rather painful to use).

Enter prototype’s solution: the Class object and Object.extend() method. Sam Stephenson uses them throughout the library (check out the source!), and they allow users like us to do simple object-oriented programming. For example:

// create an empty Person class
var Person = Class.create();   
 // define the Person interface     
Person.prototype = {                 
    initialize: function(name) {
        this.name = name;
    },
   
    show: function() {
        alert(this.name);
    }
});

var myperson = new Person(“Ken”);
// alerts "Ken"
myperson.show();

and

// create an empty Employee class
var Employee = Class.create()
// extend Person                         
Object.extend(Employee.prototype,Person.prototype);     
// extend Employee interface
Object.extend(Employee.prototype, {                 
    initialize: function(name,salary) {
        // super constructor
        Person.prototype.initialize.call(this, name)
        this.salary = salary;
    },

    show: function() {
        alert(this.name + ‘ earns ‘ + this.salary);
    }
});

var myemployee = new Employee(“Ken”, 100000000)
// alerts "Ken earns 100000000"
myemployee.show();

Not bad. No offence, but, in my opinion, prototype beats other Javascript OO approaches I’ve encountered. Still, I’m troubled that we have to define class creation, inheritance, and interfaces separately. Whatever happened to this?

class Person {
    protected var name;
   
    public Person(thename) {
        name = thename
    }

    public String show() {
       return name;
    }
}

class Employee extends Person {
    protected var salary;
       
    public Employee(thename,thesalary) {
        super(thename);
        salary = thesalary;
    }
   
    public String show() {
           return name + ‘ ‘ + salary;
    }
}

Seems a whole lot more intuitive to me, but, of course, that was Java, and the only relationship between Java and Javascript is a name suggesting either an Indonesian island or my early-morning brew. Luckily, a small extension to prototype gets us something similar. I call it Class.extend()

Object.extend(Class, {
    extend: function(source,additions) {
        var newclass = Class.create();
        if ($C(source)) {
            Object.extend($C(newclass),$C(source));
        }
        Object.extend($C(newclass), additions);
        return newclass;
    }
});

function $C(object) { return object.prototype; }

Explain? Well, Class.extend() simply combines all the class definition steps of our earlier Employee extends Person example.

Using Class.extend, we can now say the following:

var Person = Class.extend({}, {
    initialize: function(name) {
        this.name = name;
    },
   
    show: function() {
        alert(this.name);
    }
});

var Employee = Class.extend(Person, {
    initialize: function(name,salary) {
        $C(Person).initialize.call(this, name);
        this.salary = salary;
    },

    show: function() {
        alert(this.name + ‘ earns ‘ + this.salary);
    }
});

Try it out (code). It’s a small extension, but I find Class.extend() saves me a ton of hassle. In fact, I now use Class.extend() by default and can nearly pretend I’ve never heard of object prototypes.

Comments (5)