News »Browse Articles »
Access your visitor`s location with JavaScript API
+1
Access your visitor`s location with JavaScript API
Did you know Google’s JavaScript Loader API can serve up popular javascript frameworks such as jQuery, and Prototype using their content distribution network? It works like this:
google.load("prototype", "1.6");
google.load("scriptaculous", "1.8.2");
You can see a full list of supported API’s here.
Their JavaScript API now gives you access to your visitor’s location, it sets a variable google.loader.ClientLocation, and populates it with City, Region/State, Country, Latitude, Longitude.
Here’s an example:
if (google.loader.ClientLocation != null) {
document.write("Your Location Is: " +
google.loader.ClientLocation.address.city + ", "
+ google.loader.ClientLocation.address.region);
} else {
document.write("Your Location Was
Not Detected By Google Loader");
}
The avaliable properties of the google.loader.ClientLocation object are:
google.loader.ClientLocation.latitude
google.loader.ClientLocation.longitude
google.loader.ClientLocation.address.city
google.loader.ClientLocation.address.country
google.loader.ClientLocation.address.country_code
google.loader.ClientLocation.address.region
If a location cannot be determined from the visitors IP address, the google.loader.ClientLocation variable will be null.
Source:
http://www.javapronews.com/access-your-visitors-location-with-javascript-api/
google.load("prototype", "1.6");
google.load("scriptaculous", "1.8.2");
You can see a full list of supported API’s here.
Their JavaScript API now gives you access to your visitor’s location, it sets a variable google.loader.ClientLocation, and populates it with City, Region/State, Country, Latitude, Longitude.
Here’s an example:
if (google.loader.ClientLocation != null) {
document.write("Your Location Is: " +
google.loader.ClientLocation.address.city + ", "
+ google.loader.ClientLocation.address.region);
} else {
document.write("Your Location Was
Not Detected By Google Loader");
}
The avaliable properties of the google.loader.ClientLocation object are:
google.loader.ClientLocation.latitude
google.loader.ClientLocation.longitude
google.loader.ClientLocation.address.city
google.loader.ClientLocation.address.country
google.loader.ClientLocation.address.country_code
google.loader.ClientLocation.address.region
If a location cannot be determined from the visitors IP address, the google.loader.ClientLocation variable will be null.
Source:
http://www.javapronews.com/access-your-visitors-location-with-javascript-api/
+1
Enter your comment:
Pradeep 22-01-2009
This has been widely used by Google to make the user convenient by pre-selecting the user`s Area, his/her Language preference n many more things...
Search News
News Categories
What's the News?
Post a link to something interesting from another site, or submit your own original writing for the Java community to read.
Most Popular News
-
How to stand out from other Java/JEE Professionals?
Published about 14-01-2009 | Rated +3 -
10 reasons IT certification will be important in 2009
Published about 05-01-2009 | Rated +2 -
The 9 hottest skills for `09
Published about 02-01-2009 | Rated +1 -
New Features in Servlets 3.0
Published about 05-01-2009 | Rated +4
Most Recent User Submitted News
- Can a Byte object be cast to a double value?
Submitted by Balamurali | Rated 0 - Introduction to Java Server Faces
Published about 21-09-2009 | Rated 0 - Java Champion Kirk Pepperdine on Performance Tuning and Cloud Computing
Published about 24-09-2009 | Rated 0 - Tomcat 6.x AIO (tomcat with comet support)
Submitted by Satish | Rated +1







