/    Sign up×
Community /Pin to ProfileBookmark

google mapes, center map on current visitors location

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

to post a comment
PHP

4 Comments(s)

Copy linkTweet thisAlerts:
@NogDogApr 09.2007 — 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.
Copy linkTweet thisAlerts:
@BWWebDesignsauthorApr 09.2007 — 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
Copy linkTweet thisAlerts:
@BWWebDesignsauthorApr 09.2007 — Ok so now i have this site i found that when you visit a specific page
[CODE]http://www.ip2phrase.com/ip2phrase.asp?template=%2F<IP>%2F<COUNTRY>%2F<COUNTRYSHORT>%2F<REGION>%2F<CITY>%2F<ISP>%2F[/CODE]

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

[CODE]$fp = fsockopen ("www.ip2phrase.com", 80, $errno, $errstr, 30);
if (!$fp) {
echo "$errstr ($errno)<br>n";
} else {
fputs ($fp, "GET /$item HTTP/1.0rnHost: www.ip2phrase.comrnUser-Agent: MS Internet Explorerrnrn");
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>";[/CODE]


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 [CODE]fread("http://www.ip2phrase.com/ip2phrase.asp?template=%2F<IP>%2F<COUNTRY>%2F<COUNTRYSHORT>%2F<REGION>%2F<CITY>%2F<ISP>%2F",400);[/CODE]

But that through up an error
×

Success!

Help @BWWebDesigns spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.6,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,

tipper: @Samric24,
tipped: article
amount: 1000 SATS,
)...