<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=你的密钥"></script>
<div id="l-map"></div>
// 百度地图API功能
var point = null;
var map = new BMap.Map("l-map");
map.centerAndZoom(new BMap.Point(116.395645,39.929986), 7);
map.enableScrollWheelZoom(true);
//获取浏览器定位
var geolocation = new BMap.Geolocation();
geolocation.getCurrentPosition(function(res){
if(res){
//alert(JSON.stringify(res.point));
//将获取到的经纬度赋值全局变量,方便解析为详细地址使用
point = res.point;
//以该定位经纬度为地图中心显示
map.centerAndZoom(new BMap.Point(res.point.lng,res.point.lat),12);
}
});