脚本宝典收集整理的这篇文章主要介绍了PHP – 从地址获取纬度和经度,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
<htML> <form> <input tyPE="hidden" name="mapLat"> <input type="hidden" name="mapLong"> <input type="text" name="location"> <input type="submIT" name="submit" value="submit"> </form> </html> extact($_POST); if($mapLat =='' && $mapLong ==''){ // Get lat long From GOOGLE $latlong = get_lat_long($location); // create a function with the name "get_lat_long" given as below $map = explode(',',$latlong); $mapLat = $map[0]; $mapLong = $map[1]; } // function to get the address function get_lat_long($address){ $address = str_replace(" ","+",$address); $JSON = file_get_contents("http://maps.google.COM/maps/api/geocode/json?address=$address&sensor=false®ion=$region"); $json = json_decode($json); $lat = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lat'}; $long = $json->{'results'}[0]->{'geometry'}->{'location'}->{'lng'}; return $lat.','.$long; }
以上是脚本宝典为你收集整理的PHP – 从地址获取纬度和经度全部内容,希望文章能够帮你解决PHP – 从地址获取纬度和经度所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。