anthro398
February 1st, 2006, 06:54 PM
I was kind of sick last weekend and I wanted to build a web app for friends for school, but discovered that it had already been done. Instead, I played around with the Google Maps API and thought it would be kind of neat to make a visual record of where hits on my site are coming from. It isn't terribly complicated and isn't meant to replace a real user statistics application. It's just meant to be neat and it gave me a chance to play around with the api.
You can see it at [dead link]. It's still pretty raw. I didn't try to catch any exceptions and I have no idea if the geolocation database can handle international ip addresses. Aside from handling exceptions, I'd also like to limit the number of logged visits to the last 20 or 50 or some number. I don't get a lot of traffic, but I don't want the map to be too crowded to pick out inidividual hits.
The cgi works by capturing the ip address and checking if it's on the ignore list or if it's already been seen. If neither of those things are true, it sens the ip address of the requestor to a free geolocation service, http://www.hostip.info/, to gather the city, country, latitude, and longitude. Then if the ip address is new, the cgi writes the information to the xml file that the Google Maps API uses to draw icons to the map. Finally, the cgi reads the map page and the xml data and draws the map. It also substitutes a variable in map page with helpful messages about where it thinks you are.
Let me know how it works for you and what you think. I'm open to sharing development if anyone is interested in working on this.
See it at [dead link]. Update: That link is no longer live. You can see the code, though, on my projects page. http://braggtown.com/projects.html
You can see it at [dead link]. It's still pretty raw. I didn't try to catch any exceptions and I have no idea if the geolocation database can handle international ip addresses. Aside from handling exceptions, I'd also like to limit the number of logged visits to the last 20 or 50 or some number. I don't get a lot of traffic, but I don't want the map to be too crowded to pick out inidividual hits.
The cgi works by capturing the ip address and checking if it's on the ignore list or if it's already been seen. If neither of those things are true, it sens the ip address of the requestor to a free geolocation service, http://www.hostip.info/, to gather the city, country, latitude, and longitude. Then if the ip address is new, the cgi writes the information to the xml file that the Google Maps API uses to draw icons to the map. Finally, the cgi reads the map page and the xml data and draws the map. It also substitutes a variable in map page with helpful messages about where it thinks you are.
Let me know how it works for you and what you think. I'm open to sharing development if anyone is interested in working on this.
See it at [dead link]. Update: That link is no longer live. You can see the code, though, on my projects page. http://braggtown.com/projects.html