欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

通过php获取google map的坐标地址_PHP教程

程序员文章站 2022-06-14 08:34:00
...
第一步,获取坐标
";// Google HQ
$prepAddr = str_replace(' ','+',$address);
$geocode=file_get_contents('http://maps.google.com/maps/api/geocode/json?address='.$prepAddr.'&sensor=false');
$output= json_decode($geocode);
$lat = $output->results[0]->geometry->location->lat;
$lng = $output->results[0]->geometry->location->lng;
?>
第二步,将获取到的坐标嵌入到地图即可
通过php获取google map的坐标地址_PHP教程

代码就两段,很简单。

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/746588.htmlTechArticle第一步,获取坐标 ?php$address = !empty($_POST['address'])?$_POST['address']:?=$navinfor[字段名称]?;// Google HQ$prepAddr = str_replace(' ','+',$address);$geocode=file_g...