直接复制改下key就能使用
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
<style type="text/css">
body, html,#map {width: 100%;height: 100%;overflow: hidden;margin:0;font-family:"微软雅黑";}
</style>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=自己申请的key"></script>
<script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
<title>地图展示</title>
</head>
<body>
<div id="map"></div>
</body>
</html>
<script type="text/javascript">
var x = 120.04166280946251;
var y = 36.25426919033497;
var ggPoint = new BMap.Point(x,y);
/*地图初始化开始*/
var map = new BMap.Map("map");
map.centerAndZoom(ggPoint, 18);
map.addControl(new BMap.NavigationControl());
map.enableScrollWheelZoom(true);
/*地图初始化结束*/
/*坐标转换函数开始*/
translateCallback = function (data){
if(data.status === 0) {
var marker = new BMap.Marker(data.points[0]);
//marker.enableDragging(); //marker可拖拽
map.addOverlay(marker); //在地图中添加marker
var label = new BMap.Label("xx小区",{offset:new BMap.Size(20,-10)});
marker.setLabel(label); //添加百度label
map.setCenter(data.points[0]);
}
}
/*坐标转化函数结束*/
/*百度全景地图控件 start*/
var stCtrl = new BMap.PanoramaControl(); //构造全景控件
stCtrl.setOffset(new BMap.Size(20, 20));
map.addControl(stCtrl);//添加全景控件
/*百度全景地图控件 end*/
/*展示转化后的地理位置 start*/
setTimeout(function(){
var convertor = new BMap.Convertor();
var pointArr = [];
pointArr.push(ggPoint);
convertor.translate(pointArr, 1, 5, translateCallback)
}, true);
/*展示转化后的地理位置 end*/
</script>