Home  >  Article  >  Backend Development  >  php调用google地图

php调用google地图

WBOY
WBOYOriginal
2016-06-13 12:50:461322browse

php调用googlemap?
php 调用googlemap,并根据客户端发送的经纬度显示位置,怎样实现?

php
------解决方案--------------------
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(){<br />
	$ip='';<br />
	if(getenv('HTTP_CLIENT_IP') and strcasecmp(getenv('HTTP_CLIENT_IP'),'unknown')){<br />
		$ip=getenv('HTTP_CLIENT_IP');<br />
	}elseif(getenv('HTTP_X_FORWARDED_FOR') and strcasecmp(getenv('HTTP_X_FORWARDED_FOR'),'unknown')){<br />
		$ip=getenv('HTTP_X_FORWARDED_FOR');<br />
	}elseif(getenv('REMOTE_ADDR') and strcasecmp(getenv('REMOTE_ADDR'),'unknown')){<br />
		$ip=getenv('REMOTE_ADDR');<br />
	}elseif(isset($_SERVER['REMOTE_ADDR']) and $_SERVER['REMOTE_ADDR'] and strcasecmp($_SERVER['REMOTE_ADDR'],'unknown')){<br />
		$ip=$_SERVER['REMOTE_ADDR'];<br />
	}else{<br />
		$ip='127.0.0.1';<br />
	}<br />
	return $ip;<br />
}

获取用户IP地址,再从数据库里转换成经纬度,填写到google map的JS代码里。
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn