<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
body, html,#allmap {width: 100%;height: 100%;overflow: hidden;margin:0;}
#l-map{height:100%;width:78%;float:left;border-right:2px solid #bcbcbc;}
#r-result{height:100%;width:20%;float:left;}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak="></script>
<script type="text/javascript" src="http://developer.baidu.com/map/jsdemo/demo/convertor.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.2.6/jquery.min.js" type="text/javascript"></script>
<title>GPS转百度</title>
<script>
var point = new BMap.Point(116.331398,39.897445);
//判断手机浏览器是否支持定位
if(navigator.geolocation){
var geolocation = new BMap.Geolocation();//创建定位实例
geolocation.getCurrentPosition(showLocation,{enableHighAccuracy: true});//enableHighAccuracy 要求浏览器获取最佳结果
}else{
map.addControl(new BMap.GeolocationControl());//添加定位控件 支持定位
}
//处理定位后的信息
function showLocation(r){
if(this.getStatus() == BMAP_STATUS_SUCCESS){//定位成功
//新建中心点 并将地图中心移动过去
alert("百度:"+r.longitude+","+r.latitude);
}
else {
alert('failed'+this.getStatus());//定位失败
}
}
</script>
</head>
<body>
<div id="allmap"></div>
百度jsapi
</body>
</html>
相关文章
- 06-21可ping通外网,浏览器却访问不了外部网络
- 06-21笔记本(W10)能上QQ但打不开浏览器
- 06-21Microsoft Edge Canary for Mac(edge 浏览器
- 06-21浏览器调用函数时加载的两个隐含的参数this和arguments
- 06-21ios12以上微信内置浏览器键盘收起后空白问题及原键盘位置点击事件失效问题
- 06-21浏览器如何验证HTTPS证书的合法性?
- 06-21基于nginx网关的浏览器上传大文件失败问题分析
- 06-21FlashInspector 【Firefox浏览器插件,flash分析工具】
- 06-21如何得到当前浏览器是什么
- 06-21将一个字符串中指定位置进行反转