.aspx代码如下:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="插入地图.aspx.cs" Inherits="插入地图" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=NOraeOytceNxSBgQ7pY9qbrl"> </script>
</head>
<body>
<form id="form1" runat="server">
<div>
<div id="div_baiduMap" style="height:600px; width:600px; border:1px solid silver; "></div>
<script type="text/javascript">
var map = new BMap.Map("div_baiduMap");
map.centerAndZoom(new BMap.Point(116.321565, 39.979607), 11);
//0.控件设置
//平移缩放
map.addControl(new BMap.NavigationControl());
//鼠标滚轮放大缩小
map.enableScrollWheelZoom();
//...
//1.添加点击侦听
// map.addEventListener("click", function (e) {
// alert(e.point.lng + "," + e.point.lat);
// });
//2. 添加静态标识
var _p = new BMap.Point(116.321565, 39.979607);
var _m1 = new BMap.Marker(_p);
map.addOverlay(_m1);
//3. 动画
_m1.setAnimation(BMAP_ANIMATION_BOUNCE);
//4.弹出窗口
var _info1 = new BMap.InfoWindow("易美逊总部");
_m1.addEventListener("mouseover", function () { this.openInfoWindow(_info1); });
_m1.addEventListener("mouseout", function () { this.closeInfoWindow(_info1); });
//5. 标签提示
// var _opts = { position: _p, offset: new BMap.Size(25, -10) }
// var _lab = new BMap.Label("公司总部", _opts);
// map.addOverlay(_lab);
// _lab.setStyle({ color: "orange", fontSize: "14px", padding: "6px" });
//6. 自定义标识
// var _icon = new BMap.Icon("../App_imgs/LOGO40.png", new BMap.Size(40, 40));
// var _m2 = new BMap.Marker(_p, { icon: _icon });
// map.addOverlay(_m2);
</script>
</div>
</form>
</body>
</html>
效果如下: