| By Joe Danziger | Article Rating: |
|
| January 18, 2006 07:30 PM EST | Reads: |
25,575 |
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.
Geolocating by IP Address
Geolocation refers to the ability to locate a user's geographic latitude and longitude from his IP address. There are several ways of doing this each with its own benefits and drawbacks.
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
TARGET: 64.19.164.74
NAME: MONMOUTH-BLK2
NUMBER: 64.19.128.0 - 64.19.191.255
CITY: RED BANK
STATE: NEW JERSEY
COUNTRY: US
LAT: 40.35
LONG: -74.08
LAT_LONG_GRAN: City
LAST_UPDATED: 01-Jun-2001
NIC: ARIN
LOOKUP_TYPE: Block Allocation
RATING:
DOMAIN_GUESS: MONMOUTH.COM
STATUS: OK
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
The first thing you'll have to do if you haven't already is to sign up for a Google Maps API key at www.google.com/apis/maps/. This key will have to be included in any pages you're drawing maps on.
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"
type="text/javascript">
</script>
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
- Google Maps Documentation - www.google.com/apis/maps/documentation/
- NetGeo Public Database - www.caida.org/tools/utilities/netgeo/
- Hostip.info Community Database - www.hostip.info/
- MaxMind Commercial Database - www.maxmind.com/app/city/
- GVisit - www.gvisit.com/
Published January 18, 2006 Reads 25,575
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
More Stories By Joe Danziger
Joe Danziger is a senior web applications developer with Multimax, Inc., a provider of Enterprise IT Services and Solutions supporting the critical missions of the Air Force, Army, Navy, and other Department of Defense components. He is certified as an Advanced Macromedia ColdFusion MX Developer, and also maintains the Building Blocks site (www.ajaxcf.com) dedicated to AJAX and ColdFusion, as well as DJ Central (www.djcentral.com), a Website serving DJs and the electronic dance music industry.
![]() |
news desk 01/18/06 08:51:41 PM EST | |||
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. |
||||
![]() |
PaulH 01/18/06 01:15:00 AM EST | |||
you missed our geoLocator CFC: http://www.sustainablegis.com/projects/geoLocator/ |
||||
- 4th International Cloud Computing Conference & Expo Starts Today
- An Interview with Federal CIO Nominee Vivek Kundra
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- Adaptivity & Cloud Computing: Exclusive Q&A with CEO Tony Bishop
- IBM Goes After Gmail
- Ulitzer Aid Campaign for the Typhoon Ondoy Victims
- Cloud Computing Can Revitalize Your Career as Software Developer
- Google Wave Hits Wider Beta
- Cloud Computing & Federal IT - What Does the Future Hold?
- 4th International Cloud Computing Conference & Expo Starts Today
- Yahoo! Named “Platinum Sponsor” of Cloud Computing Expo
- An Interview with Federal CIO Nominee Vivek Kundra
- Deputy CIO of the CIA to Keynote 1st Annual GovIT Expo
- Cloud Computing Expo: Exclusive Q&A with Yahoo! SVP Cloud Computing
- GovIT Expo Highlights Cloud Computing
- Live Demo of Yahoo! Query Language to be Given at 4th Cloud Computing Expo
- Wave on Ulitzer: Confessions of a Google Wave Fanboy
- Adaptivity & Cloud Computing: Exclusive Q&A with CEO Tony Bishop
- IBM Goes After Gmail
- Ulitzer Aid Campaign for the Typhoon Ondoy Victims
- Cloud Computing Can Revitalize Your Career as Software Developer
- Where Are RIA Technologies Headed in 2008?
- Personal Branding Checklist
- The Top 250 Players in the Cloud Computing Ecosystem
- Wal-Mart To Sell $399 Ubuntu Linux-based Laptop with Google Operating System
- Google's OpenSocial: A Technical Overview and Critique
- Why Microsoft Loves Google's Android
- Web 2.0 Is Dead And It's Time To Get Out Of This Mess!
- i-Technology Blog: Google Trends on Java, McNealy, AJAX, and SOA Give Pause For Thought
- Android: Who Hates Google Over the Phone?
- Google Sales Surge 57% and Net Income 46% in Quarter 3
- i-Technology Blog: Is There Life Beyond Google?
- Social Network Wars: Google + Everyone Else vs Facebook





































