php调用googlemap?

WBOY
Release: 2016-06-23 14:03:10
Original
1076 people have browsed it

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;}
Copy after login

获取用户IP地址,再从数据库里转换成经纬度,填写到google map的JS代码里。

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template