| By Joe Danziger | Article Rating: |
|
| January 18, 2006 07:30 PM EST | Reads: |
25,513 |
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,513
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/ |
||||
- Practical Approaches for Optimizing Website Performance
- SQL Anywhere Server and AJAX
- The Difference Between Web Hosting and Cloud Computing
- Ajax in RichFaces 3.3, JSF 2 and RichFaces 4
- Cloud Computing on Gartner's Top 10 List and SYS-CON Events' 2010 Calendar
- IBM Hardware Chief, Intel VC Exec Arrested in Insider Trading Scam
- US Post Office Hops a Ride on NetSuite’s Cloud
- Gang of Four Creates Cloud BI Stack
- Tactical Cloud Computing Panel at 1st Annual GovIT Expo
- Confessions of a Ulitzer Addict
- AJAX World RIA Conference & Expo Kicks Off in New York City
- An Introduction to Abbot
- What is Web 3.0?
- AJAXWorld RIA Conference & Expo 2009 West: Call for Papers
- Interviewing Java Developers With Tears in My Eyes
- Adobe Enters Cloud Computing with LiveCycle
- REA Is Where RIA Becomes the Norm
- RIAs for Web 3.0 Using the Microsoft Platform
- Practical Approaches for Optimizing Website Performance
- Social Media Terrorists
- Building a Drag-and-Drop Shopping Cart with AJAX
- What Is AJAX?
- Google Maps! AJAX-Style Web Development Using ASP.NET
- Flashback to January 2006: Exclusive SYS-CON.TV Interviews on "OpenAjax Alliance" Announcement
- AJAXWorld Conference & Expo to Take Place October 2-4, 2006, at the Santa Clara Convention Center, California
- AJAX Sponsor Webcasts Are Now Available at AJAXWorld Website
- How and Why AJAX, Not Java, Became the Favored Technology for Rich Internet Applications
- "Real-World AJAX" One-Day Seminar Arrives in Silicon Valley
- AJAXWorld University Announces AJAX Developer Bootcamp
- AJAX Support In JadeLiquid WebRenderer v3.1





































