Click to See Complete Forum and Search --> : google mapes, center map on current visitors location


BWWebDesigns
04-09-2007, 01:47 PM
I am using a phoogle scrpt to generate a google map on my site with markers pulled from lat and long info from a database

But i want to be able to do the following, i need to be able to some how find out without asking, the current visitors lat and long so i can put a marker at their location without first having to ask them their location

Is there any way to get a rough idea of their location, ive seen it done on the frappr site they auto have a marker at roughly your location asking you to add your marker etc

anyone know how i can get the info i need

Thanks

NogDog
04-09-2007, 01:52 PM
You need an IP-to-location database. You'll have to do your own research on which is best and within your budget, as I've never used any of them.

BWWebDesigns
04-09-2007, 01:55 PM
is there possibly some free option afterall i only want to get the persons rough area for a few seconds and i cant really afford to pay anything

NogDog
04-09-2007, 02:03 PM
http://www.google.com/search?q=IP+location+database+free

BWWebDesigns
04-09-2007, 02:54 PM
Ok so now i have this site i found that when you visit a specific page
http://www.ip2phrase.com/ip2phrase.asp?template=%2F<IP>%2F<COUNTRY>%2F<COUNTRYSHORT>%2F<REGION>%2F<CITY>%2F<ISP>%2F

it displays on screen the information i need about myself because i am the one looking at the page

Now someone told me if i could somehow use php to get this info in the background while someone is opening my page i could seperate the info into different chunks and use that info as their rough location

because the info the page displays has the values i needed and they are seperated by a / so i was using

$fp = fsockopen ("www.ip2phrase.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>\n";
} else {
fputs ($fp, "GET /$item HTTP/1.0\r\nHost: www.ip2phrase.com\r\nUser-Agent: MS Internet Explorer\r\n\r\n");
while (!feof($fp)) {
$address = fgets($fp,1024);
}
fclose ($fp);
}
echo $address."<BR>";
$address = explode('/', $address);

$ip = $address[1];
$countryf = $address[3];
$countrys = $address[4];
$state = $address[5];
$city = $address[6];
echo $ip."<BR>";
echo $countryf."<BR>";
echo $countrys."<BR>";
echo $state."<BR>";
echo $city."<BR>";

This displays the info from the page and also splits it into the bits i need and displays them just so i can test it

This works great HOWEVER it does not display the info for my location but rather the location of the server my host is on

Any way i can modify the code i have to make it recognise the reqest as coming from the person who is visiting my site and not my host server

or ay other way of doing it where it would work, i tried fread("http://www.ip2phrase.com/ip2phrase.asp?template=%2F<IP>%2F<COUNTRY>%2F<COUNTRYSHORT>%2F<REGION>%2F<CITY>%2F<ISP>%2F",400);

But that through up an error