|
Comments
|
Today's Top SOA Links
Feature Visualize Your Visitors with Google Maps
The new art of geolocation
By: Joe Danziger
Jan. 18, 2006 07:30 PM
The availability of the Google Maps API has opened up a slew of new development possibilities and spawned a bunch of web sites that rely on this data to function. Example applications include jogging trackers, subway map overlays, and other cool ideas all made possibly by the public availability of the mapping API.
The most cost-effective source of this data is one of the publicly available databases: NetGeo, originally set up by the Cooperative Association for Internet Data Analysis (CAIDA). Although this project was stopped several years ago, the database is still available and provides a good resource for determining rough locations. Queries to this database are free, but limited. You can only send a limited number of requests through every few minutes. You query against the NetGeo database by calling the URL http://netgeo.caida.org/perl/netgeo.cgi?target=64.19.164.74. It should return the following data to the browser:
VERSION=1.0 You have some flexibility in how you store visitor IP addresses. My preferred method is to create a login_record table so that the data is always available, even after a restart. We can use ColdFusion's string functions to parse out the relevant latitude and longitude data. We'll also parse out the city, state, and country and display that info in a pop-up balloon when each point is clicked. Listing 1 contains the code to parse out these fields. Another free source of data is the community-based project at www.hostip.info. This is a newer database but it's actively being updated. You can issue queries over the web via http://api.hostip.info/get_html.php?ip=64.19.164.74&position=true, which will return results similar to NetGeo. You can also download a full copy of its IP to the location database on the site. There is also a commerical GeoIP City Database maintained by MaxMind at. www.maxmind.com/app/city.
Drawing The Map In the <head></head> section of your page, you'll have to include the following script call:
<script src="http://maps.google.com/maps?file=api&v=1&key=YOUR_API_KEY" The next step is to include an empty div right after your <body> tag which will hold the map: <div id="map" style="width: 700px; height: 500px"></div> Now that we've got all of the coordinate data, plotting points on the map is rather simple. Include the script call in Listing 2 somewhere on your page (see Figure 1) Resources
Reader Feedback: Page 1 of 1
Your Feedback
Subscribe to the World's Most Powerful Newsletters
Subscribe to Our Rss Feeds & Get Your SYS-CON News Live!
|
SYS-CON Featured Whitepapers
Most Read This Week |
|||||||||||||||||||||||||||||||||