Dutton

DoshTracker Update #2 - Ext JS and Google Maps API Integration

Shea Frederick on the extjs blog has produced a component which extends Panel and integrates with the Google Maps API here allowing you to display google maps anywhere you can use a Panel, that includes windows, viewports and layouts. This is great for the DoshTracker development as I can use this code to form the basis of the mapping displays, saving me a lot of code hacking and fiddling.

The issues I am having at the moment revolve around Google's geocoding of UK postcode data. For those who don't know, geocoding is the process of turning an address into longitude and latitude location information which can then be displayed on a map. It can be a bit hit or miss, especially in the UK where the physical area covered by a single postcode can vary widely but prior to Google providing this feature in its API, the only way of achieving this was to buy a horrendously expensive license from the Royal Mail (who own our postcodes, apparently?!?!?) making this an unfeasible option for DoshTracker.

It appears that the results you get back through the API functions are sometimes different to those you'd get typing in the same postcode into maps.google.com, a fact that they confirm in their original press release when they state that "(the) geocoder is not using the same resources as maps.google.com and may not return the same results",  but hats off to them anyway for providing the feature in the first place. For privacy reasons, I don't intend on displaying either the full postcode or a map at a sufficient zoom level to work out the precise location of notes entered into the system, so it may be that the accuracy provided by Google will suffice, but I'm designing the system to allow me to use other geocoding services in future.

In order to do this, I've separated the geocoding from the actual map display. A lot of code I've seen so far calls the geocoding functions when drawing the map in order to set the map center dynamically. This is unnecessary for me as DoshTracker will be using maps to display previously entered locations and so I plan to only geocode the hit's location when the new note or hit is added to the system and then to store that information in the database. This not only reduces the number of calls to the Google Maps API (reducing the chances of me exceeding their acceptable policies) but also means that I can substitute the geocoding component in the future with only minimal code changes.

I'm just ironing our a few bugs in the display but I'll be adding a new tab to the DoshTracker homepage over the weekend to allow you guys to test the geocoder. I'll be logging the geocoded results to a database for use in the eventual system so please feel free to geocode all of your common locations and let me know what you think. I'm particularly interested in feedback on the map zoom level and the accuracy of the results you get.

Update (13/03/2009): The most up to date version of this component is now being hosted here at Google Code.


Share this: