<!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>3D 控制罗盘</title>
<link rel="stylesheet" href="https://a.amap.com/jsapi_demos/static/demo-center/css/demo-center.css"/>
<style>
html, body, #container {
height: 100%;
width: 100%;
}
</style>
</head>
<body>
<div id="container"></div>
<script type="text/javascript"
src="https://webapi.amap.com/maps?v=1.4.15&key=您申请的key值"></script>
<script type="text/javascript">
// 创建地图实例
var map = new AMap.Map("container", {
zoom: 13,
center: [116.43, 39.92],
resizeEnable: true,
viewMode: '3D',
pinch: 45
});
AMap.plugin([
'AMap.ControlBar',
], function(){
// 添加 3D 罗盘控制
map.addControl(new AMap.ControlBar());
var deg = 0
setInterval(()=>{
deg += 0.1
map.setRotation(deg)
},20)
});
</script>
</body>
</html>
网友评论