php批量转换谷歌地图坐标为百度地图坐标_PHP教程

php中文网
发布: 2016-07-13 17:53:20
原创
1712人浏览过

获取POI lat lon
 
大众点评网
1. if you find a shop, which has the following link
www.dianping.com/shop/3174400/
2. manually attache map to make the link looks like
www.dianping.com/shop/3174400/map
3. do a view source on that page
in the middle of the page, you will find something like
p: “HETHVFZVVJDHUD”
m: $(“ShopGMap”)
shopId: “3174400″
the p: number is the encoded Lat, lon value
following is the script to decode it
 
 

jquery test


 

 
 
以上是js 方式转换。
下面是php方式
 
 
#echo $位置.”\n”;
#echo $地图x轴.”\n”;
#echo $地图y轴.”\n”;
 
$db_host = “localhost”;//服务器
$db_user = “root”;//用户名
$db_psw = “123456″;//密码
$db_name = “dianping”;//数据库名
$connection = mysql_connect($db_host,$db_user,$db_psw) or die(“连接服务器失败”);
mysql_select_db($db_name,$connection) or die(“选择数据库失败”);
 
mysql_query(“set names’utf-8′”); //utf8
 
set_time_limit(0);//防止超时。
 
$querysql = “select * from dianping ” ; //
$queryresult = mysql_query($querysql) or die(“查询数据失败”);//执行查询
 
while($row = mysql_fetch_array($queryresult)){
 
$array = decode($row['map']);
$string = $array['0'].”,”.$array['1'];
echo $string.”
”;
$id = $row['id'];
$UpdateQuery = “update dianping set map = ‘$string’ where id = ‘$id’”;
$UpdateQueryResult = mysql_query($UpdateQuery) or die(“查询数据失败”); //执行查询
}
 
/*发现有时候坐标字符串会改变,但是转换出来的坐标不会变。
$poi = ‘IJJTHFZVITEBVS’;
$poi1 = ‘IJJTGDZVITEBVA’;
$poiss = decode($poi);
$poiss1 = decode($poi1);
print_r($poi).’
\n’;
print_r($poiss).’
\n’;
print_r($poi1).’
\n’;
print_r($poiss1);
*/
function decode($poi) {
$settings = array(
‘digi’=> 16,
‘add’=> 10,
‘plus’=> 7,
‘cha’=> 36,
‘center’=> array(
‘lat’=> 34.957995,
‘lng’=> 107.050781,
‘isDef’=> true
)
);
$i = -1;
$h = 0;
$b = “”;
$j = strlen($poi);
$g = ord($poi{$j-1});
$c = substr($poi, 0, $j-1);
$j–;
 
for($e=0; $e $d = base_convert($c{$e}, $settings['cha'], 10) – $settings['add'];
if ($d>=$settings['add']) {
$d = $d- $settings['plus'];
}
 
$b .= base_convert($d, 10, $settings['cha']);
if ($d>$h) {
$i = $e;
$h = $d;
}
}
$a = base_convert(substr($b, 0, $i), $settings['digi'], 10);
$f = base_convert(substr($b, $i+1), $settings['digi'], 10);
$l = ($a+$f – intval($g))/2;
$k = ($f – $l)/100000;
$l /= 100000;
$lat = $k;
$lng = $l;
return array($lng, $lat);
}
 
 php批量转换谷歌地图坐标为百度地图坐标 - InSun - Minghacker is Insun

www.bkjia.comtruehttp://www.bkjia.com/PHPjc/478032.htmlTechArticle获取POI lat lon 大众点评网 1. if you find a shop, which has the following link www.dianping.com/shop/3174400/ 2. manually attache map to make the link looks like www.dianping...
相关标签:
百度地图
百度地图

百度地图作为新一代人工智能地图,服务覆盖全球200+城市及国家。导航可信赖、语音交互更简单、数据丰富更贴心的百度地图,致力于为用户提供更准确、更丰富、更易用的出行服务。有需要的小伙伴快来保存下载体验吧!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号