We offer a simple IP geolocation javascript for free!
After including you will able to access to the geo position (lat/long) of your visitor, get his hometown and country. The only precondition is to include a link to http://unitedcoderscom.appspot.com/.
If you want to include it on high traffic sites it could make problems because there are limits with the used webservices. We have build some caching strategies so it wont cause in the most cases. If you want to do more requests read limits in the article of making a ip2location mashup and deploy your instance directly.
Play with it and use some free Proxyserver 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>
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 the following map and the found location displayed.
You are near these cities:
We using more then one IP2geo API for an fault-tolerant script and more detailed position. Intern 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” include all these scripts – the initial loading could 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 dont forget to include a link to unitedcoderscom.appspot.com for free usage!