ball_admin/src/maptest.html

41 lines
1.4 KiB
HTML

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
<title>给多个点添加信息窗体</title>
<link rel="stylesheet" href="https://cache.amap.com/lbs/static/main1119.css" />
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=2.0&key=d58999d072ed7e5897d3900a769cfda0"></script>
</head>
<body>
<div id="container"></div>
<script type="text/javascript">
//初始化地图对象,加载地图
var map = new AMap.Map("container", {
resizeEnable: true,
mapStyle: "amap://styles/darkblue",
center: [103.55, 30.34],
viewMode: "2D", // 是否为3D地图模式
zoom: 11, // 初始化地图级别
});
var infoWindow = new AMap.InfoWindow({ offset: new AMap.Pixel(0, -30) });
var marker = new AMap.Marker({
position: [103.55, 30.34],
map: map
});
marker.content = '我是第1个Marker';
marker.on('click', markerClick);
marker.emit('click', { target: marker });
function markerClick(e) {
infoWindow.setContent(e.target.content);
infoWindow.open(map, e.target.getPosition());
}
map.setFitView();
</script>
</body>
</html>