Maison >développement back-end >tutoriel php >php调用googlemap?
php 调用googlemap,并根据客户端发送的经纬度显示位置,怎样实现?
找google的api啊
http://wenku.baidu.com/view/704d821ea76e58fafab003b0.html
简单点的,像这样,google现有的代码,但是需要共享用户的地理位置给google。
https://google-developers.appspot.com/maps/documentation/javascript/examples/map-geolocation
复杂点的,需要有一个IP个经纬度数据包。不过免费的很少,像:http://www.maxmind.com/en/geolocation_landing
然后用
function curIp(){ $ip=''; if(getenv('HTTP_CLIENT_IP') and strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')){ $ip=getenv('HTTP_CLIENT_IP'); }elseif(getenv('HTTP_X_FORWARDED_FOR') and strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')){ $ip=getenv('HTTP_X_FORWARDED_FOR'); }elseif(getenv('REMOTE_ADDR') and strcasecmp(getenv('REMOTE_ADDR'),'unknown')){ $ip=getenv('REMOTE_ADDR'); }elseif(isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] and strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')){ $ip=$_SERVER['REMOTE_ADDR']; }else{ $ip='127.0.0.1'; } return $ip;}