高德地图中当moveend事件以及zoomend事件以及隔5秒改变级别

<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<style>
		#container
		{
			width: 100%;
			height: 1000px;
			position: absolute;
			left: 0px;
			top: 0px;
		}
	</style>
	<script type="text/javascript" src="https://webapi.amap.com/maps?v=1.4.15&key=c6e183994605d131f97132d2f296d713"></script>
</head>
<body>
	<script>
		window.onload=function()
		{
				var map=new AMap.Map('container',{//对象
					zoom:11,//初始的地图级别
					center:[121,30]//初始化的地图的中心点
				});
				console.log(map.getZoom());
				console.log(map.getCenter().toString());
				/*map.on('moveend',function()
					{ 地图进行缩放的时候监听该函数,也就是点击的时候哈.缩放
						console.log(map.getZoom());
						console.log(map.getCenter().toString());
					});*/
				//设置地图的级别
				setTimeout(function()//过5秒就设置级别为15级
					{
						map.setZoom(15);
					},5000);
				map.on('zoomend',function()
					{ 地图进行缩放的时候监听该函数,也就是点击的时候哈.缩放
						console.log(map.getZoom());
						console.log(map.getCenter().toString());
					});
						
		}
	</script>
	<div id="container"></div>
</body>
</html>
posted @ 2020-08-04 20:43  贵哥的编程之路  阅读(267)  评论(0)    收藏  举报