Thursday, September 24, 2009

Gecoder response structure

I made simple test pages for version 2 and version 3 that display the geocoder response object contents prettyprinted.

First I was using toSource() method of Firefox which is a handy way to have a look inside objects. You could say that is opposite to eval().

Using non-standard toSource() debugging method means that the pages would work only with FF. I think that all the browsers have a similar method internally, but it is exposed only in Gecko browsers.

I switched to JSON.stringify(). That is also built in FF3.1+ and even in IE but only in IE8 mode. The function is made cross-browser by loading Douglas Crockfords json2.js script. You can get it from json.org.

The line breaks, spaces and indents are generated by beautify.js from jsbeautifier.org

2 comments:

Danprime said...

Hi Esa,

I was wondering if I might be able to get a copy of your source code for http://mapsapi.googlepages.com/textmarkers.htm example. I find it really interesting.

Thank you for posting all your experiments!

Esa said...

Sure. Feel free to copy the source code.

Many people are asking for a license. Nowadays I put Apache boilerplate but I can put it on any of the older code examples too if you need it.

Apache is a typical open source license that lets you do anything you want with the code except take the copyright.