Auto zoom KML content on a google map

Posted on July 27, 2007

If you’ve seen my display KML on a google map page you’ll know that it doesn’t automatically zoom up on your generated markers. That’s cause I thought it was too hard and crazy to implement.

Turns out I was wrong.

If you’re populating a google map with data from a KML file, you can automatically centre and zoom to the right place just by adding this line of code:

geoXml.gotoDefaultViewport(map)

Where geoXml is your GGeoXml object and map is your GMap2 object.

How easy is that?!

Prevent an asp.net button from doing a postback

Posted on July 25, 2007

Something that bugged me for ages in asp.net was how to prevent an asp.net button from automatically doing a postback.

To prevent a postback occuring simply make the OnClientClick event return false like this:

<asp:Button ID="button" runat="server" OnClientClick='return false' />

QuickSwitch for VS 2003

Posted on July 18, 2007

Lars Engel updated my Visual Studio QuickSwitch plugin so it can now work on Visual Studio 2003.

Not only that, but he made it even better – now you hit a checkbox to search through all open projects as well (not just the current project.)

Find his blog post here:Quick Switch for Visual Studio 2003 / .NET 1.1 where he also keeps binaries of the updated files.

Thanks Lars!

Display your KML on a Google Map

Posted on July 12, 2007

KML – the Google Earth/Maps markup language – is a handy and convenient way of displaying geographical information on a google map.

To use it though you need to store your KML on a website somewhere where Google can get at it – which makes for quick and dirty KML experimentations a bit of a pain.

SO, I’ve created a quick little Rails application that let’s you see your KML straight away – without having to go through the rigmarole of saving it in a file somewhere first.

Check it out here: http://www.thechrisoshow.com/display_kml.

To use it, just type some KML into the box, click the button, then move around on the google map – pretty straight forward!

To get you going, here’s some interesting KML as provided by the Google Maps team. Paste this in then zoom up on Sicily!

<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://earth.google.com/kml/2.0">
<GroundOverlay>
  <description>
     Overlay shows Mount Etna erupting on July 13th, 2001.
  </description>
  <name>Large-scale overlay on terrain</name>
  <LookAt>
    <longitude>15.02468937557116</longitude>
    <latitude>37.67395167941667</latitude>
    <range>30350.36838438907</range>
    <tilt>58.31228652890705</tilt>
    <heading>-16.5581842842829</heading>
  </LookAt>
  <visibility>0</visibility>
  <Icon>
    <href>http://bbs.keyhole.com/ubb/z0302a1700/etna.jpg</href>
  </Icon>
  <LatLonBox id="khLatLonBox751">
    <north>37.91904192681665</north>
    <south>37.46543388598137</south>
    <east>15.35832653742206</east>
    <west>14.60128369746704</west>
    <rotation>0</rotation>
  </LatLonBox>
</GroundOverlay>
</kml>

There’s some more cool KML samples here http://googlemapsapi.blogspot.com/2006/11/kml-on-google-maps.html

Capture session expiration in Ruby on Rails

Posted on July 10, 2007

Dave Naffis blogged about this neat plugin that handles all kinds of session manipulation stuff, including the ability to call a method when you expire a session.

This was just what the doctor ordered for me – I had some cleanup code to call on session expiration, and darned if I could figure out how to do this…

With the SessionExpiration plugin it’s a piece of cake

class SomeController < ApplicationController
  expire_session_in 5.minutes, :after_expiration => session_expiry

  def session_expiry
    # Do awesome cleanup operations here!
  end

Daves blog: http://www.naffis.com

Install SessionExpiration like this:
script/plugin install http://svn.intridea.com/svn/public/session_expiration/

calendar_helper now highlights todays date

Posted on July 09, 2007

I contributed my first ever open source patch this weekend, to Geoffrey Grosenbachs awesomely simple calendar_helper Rails plugin.

You can install this into your current rails app with:
script/plugin install http://topfunky.net/svn/plugins/calendar_helper

My humble patch added the ability to display the current date on the calendar like so (the magic blue square):

Something fun for me was how amazing it was to create a patch using subversion – you just type
svn diff  > patch_file_name.diff

And it creates this wonderful magic patch file that details all the changes you’ve made! I just had to send this to Geoffrey and he did some subversion magic to easily commit my changes.

I think this creating patch thing is gonna get addictive…

ALSO I note that Tom Armitage added some functionality into this patch as well to do with what markup the calendar uses. (It was also his first patch experience). Find him here: Another day, another release – updated calendar_helper

Open files without leaving the keyboard in Visual Studio

Posted on July 02, 2007

At the Developer Developer Developer day on Saturday I saw a great presentation done by Zi Makki on how to create Visual Studio plugins.

After the conference, I immediately ran home and started work on a plugin to fix a current pain of mine: the ability to quickly open files in Visual Studio without using the mouse.

Using Textmate on the mac, there’s a really neat fast system for switching files. You simply hit Command – T and up pops this dialog:

.

Then you simply type a portion of the file name and the results list is filtered. Hit enter and you’ve opened it up real fast!

So, I made a quick and dirty version of this for Visual Studio. It’s called QuickSwitch

Installation

1) First you need the DXCore – this is a FREE download from devexpress. Download it here and install it on your machine (you probably have to close down Visual Studio first).


2) Next, download this file QuickSwitch.zip and extract the contents into this folder (or wherever you installed DXCore):

c:\Developer Express Inc\DXCore for Visual Studio .NET\2.0\Bin\Plugins

3) Open up Visual Studio and you’ll have a new menu bar at the top DevExpress. Click this menu item and hit Options. On the options screen, add a new Keyboard Shortcut and type “Quick Switch” in the command textbox.. In the key sequence use a key sequence you want to use for this (I use Ctrl T)

Ok, now you’re ready to use it!

Using Quick Switch

Open up a solution. Hit the Quick Switch shortcut key. You’ll be greeted with this dialog listing all the files in the current project (files with the same name will have their folder names prefixed):

Start typing (no need to take your hands off the keyboard!) and the file list down the bottom will change.

Hit [enter] to automatically open the top file, or hit up and down to select a different file.

Voila – the file is opened!

Much faster than using the solution explorer!

(Yet another note: you can download the source for this plugin here)

UPDATE Rather annoyingly this version only works in Visual Studio 2005 – sorry 2003 fans!