Google Maps is one of the most useful websites to appear in recent years.
If you want to show someone on a map where your office is, or the location of a party, it’s a great tool.
You can add a link to a map very easily by clicking the buttons on Google Maps to get the code. But there is more to Google Maps than that.
If your site can determine the location of a user, geolocation can be used to customise the information displayed automatically.
So there is no need for people to enter their postcode, for example, to find the nearest branches of a business.
You could draw a map, or send the location back to the server via a web form, but first you need to find the location, so how is that done?
Not many web browsers support W3C geolocation, but the idea is that it’s extensible.
Rather than relying on a single method, there are several ways of finding out where someone is.
The least accurate is by a geographic look-up of an IP address.
Next, there are services such as Skyhook which map the locations of Wifi access points, and then there is GPS.
Some of the example services use Skyhook, which can be quite accurate.
I’m going to show how to add Google maps to your site, including one that is based on the location of the visitor.
Unfolding the maps Before you can use Google’s Maps API, which will allow you to request a map for any co-ordinates, you will need to register on the website.
To do that, you need a Google account, and you’ll receive an API key that looks like a random string of letters.