中文地址转经纬度坐标:
http://api.map.baidu.com/geocoder/v2/?output=json&ak=86E88A9a4afd0923c9ab3c3d17e9228f&address=中文地址
根据经纬度定位地址:
http://lbsyun.baidu.com/jsdemo.htm#i8_4
点击地图获取坐标:
http://lbsyun.baidu.com/jsdemo.htm#f0_3
绘制点线面:
http://lbsyun.baidu.com/jsdemo.htm#f0_7
百度地图地点标注及纠错:
http://i.map.baidu.com/api/page/poicorrect/addpoipc?business_trigger=8&city_id=301&poi_name=%E4%B8%AD%E5%B1%B1%E4%B8%AD%E5%AD%A6-%E5%85%AC%E4%BA%A4%E8%BD%A6%E7%AB%99
php算两点间距离
http://www.jb51.net/article/83580.htm
html5获取的gps坐标转百度坐标(不转成百度系坐标会有误差);
http://lbsyun.baidu.com/jsdemo.htm#a5_2
坐标转中文
//纬度在前,经度在后
$url='http://api.map.baidu.com/geocoder/v2/?callback=renderReverse&location='.$wd.','.$jd.'&output=json&ak=86E88A9a4afd0923c9ab3c3d17e9228f';
$ret=file_get_contents($url);
$ret=str_replace('renderReverse&&renderReverse(','',$ret);
$ret=str_replace('}})','}}',$ret);
$ret=json_decode($ret,true);
$cityName=$ret['result']['addressComponent']['city'];
坐标转码(gps转百度的坐标的参数是1,5)
http://lbsyun.baidu.com/index.php?title=webapi/guide/changeposition
获取当前位置,传给服务器的例子:
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=0">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<!--ios下启动webapp全屏-->
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="format-detection" content="telephone=no">
<meta http-equiv="Expires" content="-1">
<meta http-equiv="Cache-Control" content="no-cache">
<meta http-equiv="Pragma" content="no-cache">
<!--百度禁止转码-->
<meta http-equiv="Cache-Control" content="no-siteapp" />
<!-- 启用360浏览器的极速模式(webkit) -->
<meta name="renderer" content="webkit">
<!-- 针对手持设备优化,主要是针对一些老的不识别viewport的浏览器,比如黑莓 -->
<meta name="HandheldFriendly" content="true">
<!-- 微软的老式浏览器 -->
<meta name="MobileOptimized" content="320">
<!-- uc强制竖屏 -->
<meta name="screen-orientation" content="portrait">
<!-- QQ强制竖屏 -->
<meta name="x5-orientation" content="portrait">
<!-- UC强制全屏 -->
<meta name="full-screen" content="yes">
<!-- QQ强制全屏 -->
<meta name="x5-fullscreen" content="true">
<!-- UC应用模式 -->
<meta name="browsermode" content="application">
<!-- QQ应用模式 -->
<meta name="x5-page-mode" content="app">
<!-- windows phone 点击无高光 -->
<meta name="msapplication-tap-highlight" content="no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta name="apple-touch-fullscreen" content="yes"/>
<link rel="stylesheet" type="text/css" href="public/static/app4/css/store.css" />
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你自己的key"></script>
<title></title>
</head>
<body class="pub-p">
<div class="loading">
<i></i>
<i></i>
<i></i>
</div>
</body>
</html>
<script type="text/javascript" src="public/static/app4/js/zepto.min.js"></script>
<script type="text/javascript" src="public/static/app4/js/touch.min.js"></script>
<script type='text/javascript'>
$(document).on('tap','ul li h3',function(e){
e.preventDefault();
var $self = $(this);
var $li = $self.parent();
$li.addClass('on').siblings('li').removeClass('on');
e.stopPropagation();
});
var x=0;
var y=0;
getLocation();
function getLocation(){
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){
var mk = new BMap.Marker(r.point);
x=r.point.lat;
y=r.point.lng;
$.ajax({
type: "post",
url: './index.php?_c=app4&_f=home_ajax',
data: {city_id:{{city_id}},jd:y,wd:x},
dataType: "json",
success: function(data){
var html='<section class="con-box store-list"><ul>';
var ahtml='';
ahtml+='<section class="con-box addr-box">';
ahtml+='<span>'+data.city_nowName+'共'+data.city_shopNum+'家体验店 (全国'+data.china_shopNum+'家)'+'</span>';
ahtml+='<a style="color:#999" href="./index.php?_c=app4&_f=city&city_id='+data.city_id+'">'+data.city_nowName+'<i></i></a>';
ahtml+='</section>';
$.each(data.cityList,function(i,n){
var fclass='';
var ftext='';
var shop_img='';
if(i==0){
fclass='class="on"';
ftext='离我最近';
}
if(n.img&&n.img!=''){
shop_img=n.img;
}else{
shop_img='public/static/app4/img/store-img.jpg';
}
html+='<li '+fclass+'>';
html+='<h3>'+n.shopName+' <i></i></h3>';
html+='<div class="list-detail">';
html+='<p class="distance">';
html+=n.position+'km';
html+='<span>'+ftext+'</span>';
html+='</p>';
html+='<img src="'+shop_img+'" alt=""/>';
html+='<p class="address clearfix">';
html+='地址:'+n.address;
html+='<a href="./index.php?_c=app4&_f=store_map&shop_id='+n.id+'">查看地图</a>';
html+='</p>';
html+='<p class="btn-group">';
html+='<a class="service" href="tel:4006355235">联系客服</a>';
html+='<a class="appointment" href="./index.php?_c=app4&_f=store_book&shop_id='+n.id+'">预约到店</a>';
html+='<a href="tel:'+n.tel+'" class="telephone">联系门店</a>';
html+='</p>';
html+='</div>';
html+='</li>';
});
if(data.cityList.length==0){
html+='<p>没有相关门店</p>';
}
html+='</ul></section>';
$('body').html(ahtml+html);
},
error:function(err){
alert('提交失败,请联系开发人员');
}
});
}
else {
alert("定位失败,位置信息是不可用");
}
},{enableHighAccuracy: true})
}
</script>
- 相关文章
- phpexcel设置行高及列宽,背景颜色,
- 单点登录sso原理及php实现方式及de
- 在php中用curl请求java接口无法获
- 免费ip地址查询接口
- php,java,android, aes加解密-加密
- 地图上计算两点间的距离
- php中empty,is_null,isset的区别
- windows及linux下composer安装教程
- 一种精妙的数据查询与存储方式
- 微信扫码登录
- 热门文章
- win7中将文件拷贝到虚拟机linux下
- phpexcel设置行高及列宽,背景颜色,
- rabbitmq无法启动
- intellij idea不显示git push按钮
- php7中使用mongodb的aggregate进行
- centos7.4 64位下swoole安装及配置
- laravel页面静态化的方法
- navicate连接mycat报1184错误
- 单点登录sso原理及php实现方式及de
- devops-jenkins容器为pending状态
- 好评文章
- phpexcel设置行高及列宽,背景颜色,
- php7中使用mongodb的aggregate进行
- intellij idea打开文件所在文件夹
- windows下使用MongoDB Compass Com
- win7中将文件拷贝到虚拟机linux下
- laravel 中悲观锁 & 乐观锁的使用
- 单点登录sso原理及php实现方式及de
- navicate连接mycat报1184错误
- rabbitmq无法启动
- laravel整合dingo/api方法步骤:jwt
- 我的项目
- 【github】www.github.com/hurong241
- 【码云】gitee.com/hu_rong/projects
- 【docker hub】hub.docker.com/repositories/hurong241
- 【packagist】packagist.org/users/hurong241/packages
- 站点信息
- 建站时间:2011年
- 文章数:607篇
- 浏览数:943478