Monday, September 10, 2007

As part of my Virtual Earth application I thought it'd be pretty sweet to integrate the browser's address bar so people could bookmark locations and send them to friends. This was pretty cool, but then I got really excited about integrating the browser's back and forward buttons to go between previously visited locations. Combined with the transition animation I'm having way too much fun sitting around and bouncing between locations on the map. If you haven't tried it, I definitely suggest you do!

I ended up making the code pretty reusable because it seems like a handy thing to have around. I also made a simple demo app to show the effect in a more approachable manner.

Demo page

Source

The code should be pretty easy to leverage, you just attach change handlers to the properties that you want to know when they've changed:

Historian.Instance["x"].Changed += this.HandleXChanged;
Historian.Instance["y"].Changed += this.HandleYChanged;
And any time you want to set a property and have it appear as a bookmark location, just set the property:

Historian.Instance["x"].Value = this.destination.X.ToString();
Historian.Instance["y"].Value = this.destination.Y.ToString();
Voila!

The one super cautionary caveat to this is that IT DOES NOT WORK ON SAFARI! Ugh. I spent a bunch of time investigating this and have absolutely grown to hate browsers and all their wackiness and wonkiness and have *every* intention of getting this to work on Safari, but just not today. It works fine on Firefox on Mac, but I just had to move on for a little while- it's driving me absolutely nuts. Some Silverlight features should be arriving in the next release which will ease my pain and suffering on Safari and I'm hoping to get it supported when that's available. Sorry!