Free IP to Geo Location script

We offer a simple IP geolocation javascript for free!
After including you will be able to determine the geo position (lat/long) of your visitor, get his hometown and country. The only precondition is to include a link to http://united-coders.com/.
If you want to include it on high traffic sites it could make problems because there are limitations due to the conditions of the used webservices. We have build some caching strategies so it won't be an issue in the most cases. If you want to do more requests please read about limitations in the article of making a ip2location mashup and deploy your instance directly.
Play with it and use some free proxy servers to change your own IP!
How to include?
- <script type="text/javascript" src="http://pyunitedcoders.appspot.com/geo_data.js?key=#google_key#"></script>
- <script type="text/javascript">
- document.write(com.unitedCoders.geo.generate_map(500, 400));
- </script>
- Powered by <a href="http://www.united-coders.com/christian-harms/free-ip-location-script">united-coders.com</a>.
The backlink is not optional!
The google key parameter is optional. You need it if you want to use the google ip location api and/or the static google map to show all found locations. After printing the generate_map function it will display the following map and the found location.
You are near these cities:
We are using more than one IP2geo API for a more fault-tolerant script and more accurate position determination. Internally we call ipinfodb and hostip and after including our geo location javascript there will added more javascripts (for more locations):
- maxwind.com
- the google ajax api - if the key parameter is set
- WIPmedia.com
Our javascript "ip-geolocation and data aggregator" includes all these scripts - so the initial loading may take a while. A second request (after reload or from a second page) of the same visitor will be cached. After all a global object with all data will generated based on the calling ip. In the javascript context all data are available and/or you can use the javascript html generator function to generate simple html code.
The com.unitedCoders.geo object
- com.unitedCoders.geo = {
- ll : [ { country: 'Germany', city: 'Esslingen', long: 9.3, lat:48.75, name:'iplocationtools'},
- { country: 'Germany', city: 'Waldenbuch', long: 9.1333, lat:48.6333, name:'maxwind'},
- { country: 'GERMANY (DE)', city: 'Karlsruhe', long: 8.4, lat: 49.05, name: 'hostip' }],
- getLat: function(), // this is computed with the ll-coordinates
- getLong: function(), // this is computed with the ll-coordinates
- generate_map: function(width, height),
- }
the generated html-code
First you have to add to your page using our geo location script some css-styles if you want to design the following pure html lines. For simple usage there exists the id "local_map".
- <div id="local_map">
- <img src="http://maps.google.com/staticmap?size=320x240&key=your_google_key&markers=48.75,9.3,midblue1%7C49.05,8.4,midgreen2%7C48.6333,9.1333,midred3%7C48.8111,8.94444,black"/>
- <ol>
- <li>iplocationtools: Esslingen, Germany</li>
- <li>hostip: Karlsruhe, GERMANY (DE)</li>
- <li>maxmind: Waldenbuch, Germany</li>
- </ol>
- </div>
The google map example use the google static map api so there is only one large url with the geo location parameters and the text lines below with the geo location service provider data. Feel free to use the javascript data directly or build better html widgets. But don't forget to include a link to united-coders.com for free usage!
Trackback URL for this post:
Wieviel Requests schafft so eine app engine?
from Netzfundstücke, Browserspiele, Eigenversuche on Wed, 03/10/2010 - 20:54Vor einiger Zeit hab ich ein Geo Location Aggregator auf united-coders.com vorgestellt. Lange wurde dies auf einer app engine nur mit wenigen Requests genutzt. Doch irgendwann nutzt doch jemanden einen freien Dienst und dann werden die freien Limits irgen

Comments
Great article.
Is there a way to exclude the results provided by WIPmania?
After checking the last 1000 visitors the wipmania api call is removed. The black locator will better match the visitors location!
thanks for your free script.
corro.info
Can you tell me how to get the ajax request working with
http://ipinfodb.com/ip_query.php?ip ,
i tried But its not working
the code i m using is like
var xmlhttp
function requestt()
{
xmlhttp=GetXmlHttpObject();
if (xmlhttp==null)
{
alert ("Your browser does not support XMLHTTP!");
return;
}
var url="http://ipinfodb.com/ip_query.php?ip";
url=url+"&sid="+Math.random();
xmlhttp.onreadystatechange=stateChanged;
xmlhttp.open("GET",url,true);
xmlhttp.send(null);
}
function stateChanged()
{
if (xmlhttp.readyState==4)
{
var xmlDoc=xmlhttp.responseXML.documentElement;
alert(xmlhttp.responseXML);
// **** showing null **//
}
}
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
{
// code for IE7+, Firefox, Chrome, Opera, Safari
return new XMLHttpRequest();
}
if (window.ActiveXObject)
{
// code for IE6, IE5
return new ActiveXObject("Microsoft.XMLHTTP");
}
return null;
}
Hi Ritesh,
you cant access with the XMLHttpRequest to an other domain than yours!
1. Use the JSONP-API from IPInfoDB to make cross-domain requests.
2. Or just include the offered Javascript like described in the example. Than there is no need to do the requests. Why do you try to access only one provider instead of let aggregating 4 provider form our script ?
Hoping this helps, Christian.
hi dear
thanx
its working and displaying near by map
so i would like to ask u
how do i pass a particular ip address and findout its location in this routine
thanx in advance
The live demo will use your calling ip directly and there is no parameter too set the ip. If you want to find the position for other IPs use the described API calls.