PHP Code to retrieve the Longitude and Latitude for given IP Address
IP 2 Loc hosted at http://ad.protonmania.com
After saw the Ajax Powered IP to Location finder by Seomoz , I've decided to dig the net on how to do that using CakePHP .
Basically , I'll get the IP given by the user via $_POST or $_GET, filter it and try to get the longitude and latitude value from 3rd party site, in this case I'm using http://netgeo.caida.org/
Example http://netgeo.caida.org/perl/netgeo.cgi?target=202.188.1.5
Then filter the result, do some PHP coding and only get the Latitude and Longitude.
Pass that value to Google Map engine, and voila.
Reference URL
CakePHP = http://cakephp.org
Google Map Account = http://code.google.com/apis/maps/signup.html
CakePHP - Google Map Tutorial = http://bakery.cakephp.org/articles/view/adding-a-google-map-to-your-app
Example : http://ad.protonmania.com/ip2loc
Salam saudara;
ReplyDeletesaya cuba nak improvise ip 2 location using google map ni..
Tapi saya rasa mcm tak berjaya pulak..
Saya guna url ni: http://netgeo.caida.org/perl/netgeo.cgi?target=10.1.9.227
ip address saya: 10.1.9.227.
Tp biler saya press enter, saya dpt response ini:
VERSION=1.0
TARGET: 10.1.9.227
NAME: RESERVED-10
NUMBER: 10.0.0.0 - 10.255.255.255
CITY: MARINA DEL REY
STATE: CALIFORNIA
COUNTRY: US
LAT: 33.98
LONG: -118.45
LAT_LONG_GRAN: City
LAST_UPDATED: 16-May-2001
NIC: ARIN
LOOKUP_TYPE: Block Allocation
RATING:
DOMAIN_GUESS: iana.org
STATUS: OK
Sedangkan saya kat Malaysia..
Mcmana saya nak buat supaya dia boleh detect Latitude dan Longitude yg betul?
Terima Kasih saudara.
Netgeo punya database dah expired. Kalau nak dapat IP malaysia, cuba guna Yahoo API atau kena laa beli dari ip2location nyer database.
ReplyDeleteLagipun ISP kita masih belum implement long/latt valiue dalam return query
cuba yg nih, example yahoo api
ReplyDeletehttp://lerdorf.com/php/ymap/geo1.php?location=202.188.1.5
I'll have been using the MamakSpot website soon! I think it's going to be an important tool and I just want to learn new things about it. Thanks for sharing this and I hope you still posting this kind of implements. 23jj
ReplyDelete