高德地图-旋转地图动画

560 阅读1分钟

✨ 效果图

rotation1.gif

💥Demo

<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title> 高德地图旋转动画 </title>
    <style>
        html,
        body,
        #map {
            width: 100%;
            height: 100%;
            margin: 0;
            padding: 0;
        }
    </style>
</head>

<body>
    <div id="map"></div>
    <script src="https://webapi.amap.com/maps?v=2.0&key=0e8324eccfcd9c8524925ad0e506bbab"></script>
    <script src="https://webapi.amap.com/loca?v=2.0.0&key=0e8324eccfcd9c8524925ad0e506bbab"></script>
    <script>
        var map =  new AMap.Map('map', {
            viewMode: '2D',
            zoom: 17,
            center: [113.347872,23.181251],
            mapStyle: 'amap://styles/darkblue',
            showBuildingBlock: false,
            showLabel: false,
        });

        var loca = window.loca = new Loca.Container({
            map,
        });

        map.on('complete', function () {
            loca.animate.start();
            animate()
        });
      
        function animate(){
            loca.viewControl.addAnimates([{
              rotation: {
                value: 3600,
                control: [[0, 3600], [1, 3600]],
                timing:  [1, 1, 1, 1],
                duration: 6000000,
              },
              rotation: {
                value: 7200,
                control: [[0, 7200], [1, 7200]],
                timing:  [1, 1, 1, 1],
                duration: 6000000,
              },
            }
            ]);
      }
    </script>
</body>

</html>