2
A
回答
3
一旦找到用户的IP地址$_SERVER['REMOTE_ADDR']
,您可以使用API,如http://ipinfodb.com/ip_location_api.php。它似乎可以获得用户的城市,如果这对您的经度/纬度来说足够准确。
5
0
使用上述浏览器的地理定位方法(请注意地理位置不是HTML5规范的一部分),或者如果浏览器不支持它,然后用雅虎placefinder从国家& ZIP /邮政编码查询用户位置。
这样你的应用程序适用于每个人。
0
$country=file_get_contents('http://api.hostip.info/get_html.php?ip=');
echo $country;
// Reformat the data returned (Keep only country and country abbr.)
$only_country=explode (" ", $country);
echo "Country : ".$only_country[1]." ".substr($only_country[2],0,4);
ipinfodb会给出与google maps api中使用的单位相同的单位吗?如(1.234,0.123)lat/lng对 – Nyxynyx 2011-05-17 22:06:37