Thursday, September 14, 2006

GOOGLE API - Another tips with Google Maps

I've discovered two new functions in google maps api release 2 : Geographical localisation from postal address and multitab info box.

Geographical localisation with Google API

In one of my first entries in this blog I've describe a method to search geographical localisation from postal address. This method had two problems for me :

  1. I must separate each element of my postal address (street, town and country)
  2. I'm not sure this service will be available during long time
Google Maps API offers the solution with Geocoder.

One of the most simple solution to extract longitude and latitude is to use it thru http call like this :
http://maps.google.com/maps/geo?q=adresse+recherchee&output=csv&key=abcdefg
Where :
  • q= : postal address to search. For example : waterloo+bridge+london
  • output= : file format to send response. You can choose xml, kml, json or csv. The csv format is the most simple.
  • key= : your Google Maps API key

CSV format response send four values : code status (200 if all is good), zoom level, latitude and logitude.

Multi tabs info box

If you want to display information box with multiple tabs, you just have to replace the call marker.openInfoWindowHtml(bulle);, like I've described it in a precedent article, by marker.openInfoWindowTabsHtml(infoTabs); where infoTabs is defined like this :
var infoTabs = [
new GInfoWindowTab("Tab1 title", "Content of tab 1"),
new GInfoWindowTab("Tab2 title", "Content of tab 2")
];

0 comments: