<!doctype html>
<html>
<head>
<meta http-equiv=content-type content=text/html; charset=utf-8 />
<title>百度地图</title>
<script type=text/javascript>
var iscreatr=false;
function initialize() {
var x = 116.4035;//设置默认标注点x
var y = 39.915;//设置默认标注点y
//---------------------------------------------基础示例---------------------------------------------
var map = new bmap.map(allmap,{minzoom:12,maxzoom:20});// 创建map实例,将地图挂到那个容器,用id表示
map.centerandzoom(new bmap.point(x,y),15); //初始化时,即可设置中心点和地图缩放级别。
//map.centerandzoom(成都,13); // 初始化地图,设置中心点坐标和地图级别。
map.enablescrollwheelzoom(true);//鼠标滑动轮子可以滚动
var point = new bmap.point(x,y);//默认
// 创建标注对象并添加到地图
var marker = new bmap.marker(point);
var label = new bmap.label(默认提示,{offset:new bmap.size(20,-10)});
marker.setlabel(label)
map.addoverlay(marker);
marker.enabledragging(); //可拖拽
marker.addeventlistener(dragend, function(e){//将结果进行拼接并显示到对应的容器内
document.getelementbyid(r-result).innerhtml = e.point.lng + , + e.point.lat;//打印拖动结束坐标
});
}
function loadscript() {
var script = document.createelement(script);
script.src = http://api.map.baidu.com/api?v=1.4&callback=initialize;
document.body.appendchild(script);
}
window.onload = loadscript;
</script>
</head>
<body>
<div id=r-result style=float:left;width:100px;>坐标</div>
<div id=allmap style=width: 800px; height: 500px></div>
</body>
</html>