Accessibility options


Find a person's location with Google Maps

Author: Nigel Whitfield
Date: Wed, 14 Apr 2010 09:30:00 GMT

How to add geographic information to your websites using Google Maps and Javascript

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.

But how do you do it? Well, the web standards organisation W3C has developed a geolocation API, designed to allow you to determine someone’s location in Javascript.

Javascript provides a way for your web pages to identify where a user is.

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.

Next, there are a few things to add to your web page. First, include the Google Maps Javascript, like this:

More features

Find legal advice and services online
Make the most of legal advice freely available on the internet Thanks to the internet you can do several things online that used to require a trip to a lawyer’s office, such as applying for a ...
10 useful free Google tools
Best known for its search engine, Google has developed a range of interesting and useful free tools. Here’s our pick of them Google made its name as a search engine but, over the years, it has ...
Working with windows in Windows
Microsoft Windows is all about – perhaps unsurprisingly – windows. We explain how to master them It may be stating the obvious, but windows are a fundamental part of Microsoft Windows. Almost ...
How to spot and avoid online scammers
Fake emails and websites can look very realistic, and trick thousands – but we explain how to outsmart them According to the website Bank Safe Online, 20 million UK citizens now access their ...
How to install and configure a monitor
Setting up a new display can be fiddly – we explain how to do it Not only are flat-panel LCD monitors cheaper than ever, but they are also bigger, brighter, clearer and easier to use. Replacing ...

Advertisement starts


Advertisement

Advertisement ends

News

Intel’s new Core vPro starts PC fight-back in the enterprise
Intel brings Sandy Bridge to business systems with features to keep the ...

Reviews

Dell PowerEdge M-Series Blade Server review
An impressive blade server system that can match anything from HP and ...

Features

Working with windows in Windows
Microsoft Windows is all about – perhaps unsurprisingly – windows. We ...

Workshops

Faster Windows with fewer visual effects
Fine-tuning the way Windows uses visual effects can improve performance in XP, Vista and 7

Videos

Review: Intel Classmate PC
Review: Intel Classmate PC. A classroom computer that's shock-resistant -

Free newsletter

Enter your email address below and receive your Free technology newsletter.

 
 
 

Advertisement starts



Advertisement ends