| By Joe Danziger | Article Rating: |
|
| January 18, 2006 07:30 PM EST | Reads: |
24,944 |
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 24,944
Copyright © 2006 SYS-CON Media, Inc. — All Rights Reserved.
Syndicated stories and blog feeds, all rights reserved by the author.
About 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/ |
||||
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Ulitzer’s Amazing First 30 Days in Public Beta
- "Government IT Expo" to Highlight Cloud Computing and SOA
- Will Ulitzer Dominate News Content on The Web? -Gartner
- Clear Toolkit 4: The Road Map
- Creating Adobe AIR Native Menu with Flash CS4
- Ulitzer Responds to Published Reports
- Ulitzer vs. Ning - a Quick Review
- Adobe AIR: Creating Dock and System Tray Icon Menus
- Social Media Terrorists
- AJAX World RIA Conference & Expo Kicks Off in New York City
- Web Services Using ColdFusion and Apache CXF
- Adobe Takes LiveCycle into the Cloud
- Ulitzer’s Amazing First 30 Days in Public Beta
- Adobe Creates a Sandbox in the Sky
- "Government IT Expo" to Highlight Cloud Computing and SOA
- Will Ulitzer Dominate News Content on The Web? -Gartner
- The Role of an RIA in the Enterprise
- Clear Toolkit 4: The Road Map
- Creating Adobe AIR Native Menu with Flash CS4
- The Next Programming Models, RIAs and Composite Applications
- Constructing an Application with Flash Forms from the Ground Up
- AJAX World RIA Conference & Expo Kicks Off in New York City
- CFEclipse: The Developer's IDE, Eclipse For ColdFusion
- Personal Branding Checklist
- Adobe Flex 2: Advanced DataGrid
- i-Technology Viewpoint: We Need Not More Frameworks, But Better Programmers
- The Asynchronous CFML Gateway
- Building a Zip Code Proximity Search with ColdFusion
- Web Services Using ColdFusion and Apache CXF








































