高德地图轨迹回放

<!-- 重点参数:renderOptions -->
<!doctype html>
<html lang="zh-CN">

<head>
    <!-- 原始地址://webapi.amap.com/ui/1.0/ui/misc/PathSimplifier/examples/index.html -->
    <base href="http://webapi.amap.com/ui/1.0/ui/misc/PathSimplifier/examples/" />
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no, width=device-width">
    <title>轨迹展示&巡航</title>
    <style>
    html,
    body,
    #container {
        width: 100%;
        height: 100%;
        margin: 0px;
    }

    #loadingTip {
        position: absolute;
        z-index: 9999;
        top: 0;
        left: 0;
        padding: 3px 10px;
        background: red;
        color: #fff;
        font-size: 14px;
    }
    </style>
</head>

<body>
    <div id="container"></div>
    <script type="text/javascript" src='http://webapi.amap.com/maps?v=1.3&key=你自己的key'></script>
    <!-- UI组件库 1.0 -->
    <script src="http://webapi.amap.com/ui/1.0/main.js"></script>
    <script type="text/javascript">
    //创建地图
    var map = new AMap.Map('container', {
        zoom: 4
    });

    AMapUI.load(['ui/misc/PathSimplifier', 'lib/$'], function(PathSimplifier, $) {

        if (!PathSimplifier.supportCanvas) {
            alert('当前环境不支持 Canvas!');
            return;
        }

        //just some colors
        var colors = [
            "#3366cc", "#dc3912", "#ff9900", "#109618", "#990099", "#0099c6", "#dd4477", "#66aa00",
            "#b82e2e", "#316395", "#994499", "#22aa99", "#aaaa11", "#6633cc", "#e67300", "#8b0707",
            "#651067", "#329262", "#5574a6", "#3b3eac"
        ];

        var pathSimplifierIns = new PathSimplifier({
            zIndex: 100,
            //autoSetFitView:false,
            map: map, //所属的地图实例

            getPath: function(pathData, pathIndex) {

                return pathData.path;
            },
            getHoverTitle: function(pathData, pathIndex, pointIndex) {

                if (pointIndex >= 0) {
                    //point 
                    return pathData.name + ',点:' + pointIndex + '/' + pathData.path.length;
                }

                return pathData.name + ',点数量' + pathData.path.length;
            },
            renderOptions: {
                pathLineStyle: {
                    dirArrowStyle: true
                },
                getPathStyle: function(pathItem, zoom) {

                    var color = colors[pathItem.pathIndex % colors.length],
                        lineWidth = Math.round(4 * Math.pow(1.1, zoom - 3));

                    return {
                        pathLineStyle: {
                            strokeStyle: color,
                            lineWidth: lineWidth
                        },
                        pathLineSelectedStyle: {
                            lineWidth: lineWidth + 2
                        },
                        pathNavigatorStyle: {
                            fillStyle: color
                        }
                    };
                }
            }
        });

        window.pathSimplifierIns = pathSimplifierIns;

        $('<div id="loadingTip">加载数据,请稍候...</div>').appendTo(document.body);

        $.getJSON('http://a.amap.com/amap-ui/static/data/big-routes.json', function(d) {

            $('#loadingTip').remove();

            var flyRoutes = [];

            for (var i = 0, len = d.length; i < len; i++) {

                if (d[i].name.indexOf('乌鲁木齐') >= 0) {

                    d.splice(i, 0, {
                        name: '飞行 - ' + d[i].name,
                        path: PathSimplifier.getGeodesicPath(
                            d[i].path[0], d[i].path[d[i].path.length - 1], 100)
                    });

                    i++;
                    len++;
                }
            }

            d.push.apply(d, flyRoutes);

            pathSimplifierIns.setData(d);

            //initRoutesContainer(d);

            function onload() {
                pathSimplifierIns.renderLater();
            }

            function onerror(e) {
                alert('图片加载失败!');
            }

            var navg2 = pathSimplifierIns.createPathNavigator(7, {
                loop: true,
                speed: 500000,
                pathNavigatorStyle: {
                    width: 16,
                    height: 32,
                    content: PathSimplifier.Render.Canvas.getImageContent('./imgs/car.png', onload, onerror),
                    strokeStyle: null,
                    fillStyle: null
                }
            });

            navg2.start();
        });
    });
    </script>
</body>

</html>
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是Vue高德地图轨迹回放的示例代码: ```vue <template> <div id="map-container"> <div id="map"></div> <div class="control-panel"> <button @click="play">播放</button> <button @click="pause">暂停</button> <button @click="stop">停止</button> </div> </div> </template> <script> export default { data() { return { map: null, trackmarker: null, timer: null, currentIndex: 0, path: [ [116.405289, 39.904987], [116.406786, 39.90424], [116.407651, 39.904405], [116.408537, 39.90456], [116.409423, 39.904715], [116.410309, 39.90487], [116.411195, 39.905025], [116.412081, 39.90518], [116.412967, 39.905335], [116.413853, 39.90549], [116.414739, 39.905645], [116.415625, 39.9058], [116.416511, 39.905955], [116.417397, 39.90611], [116.418283, 39.906265], [116.419169, 39.90642], [116.420055, 39.906575], [116.420941, 39.90673], [116.421827, 39.906885], [116.422713, 39.90704], [116.423599, 39.907195], [116.424485, 39.90735], [116.425371, 39.907505], [116.426257, 39.90766], [116.427143, 39.907815], [116.428029, 39.90797], [116.428915, 39.908125], [116.429801, 39.90828], [116.430687, 39.908435], [116.431573, 39.90859], [116.432459, 39.908745], [116.433345, 39.9089], [116.434231, 39.909055], [116.435117, 39.90921], [116.436003, 39.909365], [116.436889, 39.90952], [116.437775, 39.909675], [116.438661, 39.90983], [116.439547, 39.909985], [116.440433, 39.91014], [116.441319, 39.910295], [116.442205, 39.91045], [116.443091, 39.910605], [116.443977, 39.91076], [116.444863, 39.910915], [116.445749, 39.91107], [116.446635, 39.911225], [116.447521, 39.91138], [116.448407, 39.911535], [116.449293, 39.91169], [116.450179, 39.911845], [116.451065, 39.912], [116.451951, 39.912155], [116.452837, 39.91231], [116.453723, 39.912465], [116.454609, 39.91262], [116.455495, 39.912775], [116.456381, 39.91293], [116.457267, 39.913085], [116.458153, 39.91324], [116.459039, 39.913395], [116.459925, 39.91355], [116.460811, 39.913705], [116.461697, 39.91386], [116.462583, 39.914015], [116.463469, 39.91417], [116.464355, 39.914325], [116.465241, 39.91448], [116.466127, 39.914635], [116.467013, 39.91479], [116.467899, 39.914945], [116.468785, 39.9151], [116.469671, 39.915255], [116.470557, 39.91541], [116.471443, 39.915565], [116.472329, 39.91572], [116.473215, 39.915875], [116.474101, 39.91603], [116.474987, 39.916185], [116.475873, 39.91634], [116.476759, 39.916495], [116.477645, 39.91665], [116.478531, 39.916805], [116.479417, 39.91696], [116.480303, 39.917115], [116.481189, 39.91727], [116.482075, 39.917425], [116.482961, 39.91758], [116.483847, 39.917735], [116.484733, 39.91789], [116.485619, 39.918045], [116.486505, 39.9182], [116.487391, 39.918355], [116.488277, 39.91851], [116.489163, 39.918665], [116.490049, 39.91882], [116.490935, 39.918975], [116.491821, 39.91913], [116.492707, 39.919285], [116.493593, 39.91944], [116.494479, 39.919595], [116.495365, 39.91975], [116.496251, 39.919905], [116.497137, 39.92006], [116.498023, 39.920215], [116.498909, 39.92037], [116.499795, 39.920525], [116.500681, 39.92068], [116.501567, 39.920835], [116.502453, 39.92099], [116.503339, 39.921145], [116.504225, 39.9213], [116.505111, 39.921455], [116.505997, 39.92161], [116.506883, 39.921765], [116.507769, 39.92192], [116.508655, 39.922075], [116.509541, 39.92223], [116.510427, 39.922385], [116.511313, 39.92254], [116.512199, 39.922695], [116.513085, 39.92285], [116.513971, 39.923005], [116.514857, 39.92316], [116.515743, 39.923315], [116.516629, 39.92347], [116.517515, 39.923625], [116.518401, 39.92378], [116.519287, 39.923935], [116.520173, 39.92409], [116.521059, 39.924245], [116.521945, 39.9244], [116.522831, 39.924555], [116.523717, 39.92471], [116.524603, 39.924865], [116.525489, 39.92502], [116.526375, 39.925175], [116.527261, 39.92533], [116.528147, 39.925485], [116.529033, 39.92564], [116.529919, 39.925795], [116.530805, 39.92595], [116.531691, 39.926105], [116.532577, 39.92626], [116.533463, 39.926415], [116.534349, 39.92657], [116.535235, 39.926725], [116.536121, 39.92688], [116.537007, 39.927035], [116.537893, 39.92719], [116.538779, 39.927345], [116.539665, 39.9275], [116.540551, 39.927655], [116.541437, 39.92781], [116.542323, 39.927965], [116.543209, 39.92812], [116.544095, 39.928275], [116.544981, 39.92843], [116.545867, 39.928585], [116.546753, 39.92874], [116.547639, 39.928895], [116.548525, 39.92905], [116.549411, 39.929205], [116.550297, 39.92936], [116.551183, 39.929515], [116.552069, 39.92967], [116.552955, 39.929825], [116.553841, 39.92998], [116.554727, 39.930135], [116.555613, 39.93029], [116.556499, 39.930445], [116.557385, 39.9306], [116.558271, 39.930755], [116.559157, 39.93091], [116.560043, 39.931065], [116.560929, 39.93122], [116.561815, 39.931375], [116.562701, 39.93153], [116.563587, 39.931685], [116.564473, 39.93184], [116.565359, 39.931995], [116.566245, 39.93215], [116.567131, 39.932305], [116.568017, 39.93246], [116.568903, 39.932615], [116.569789, 39.93277], [116.570675, 39.932925], [116.571561, 39.93308], [116.572447, 39.933235], [116.573333, 39.93339], [116.574219, 39.933545], [116.575105, 39.9337], [116.575991, 39.933855], [116.576877, 39.93401], [116.577763, 39.934165], [116.578649, 39.93432], [116.579535, 39.934475], [116.580421, 39.93463], [116.581307, 39.934785], [116.582193, 39.93494], [116.583079, 39.935095], [116.583965, 39.93525], [116.584851, 39.935405], [116.585737, 39.93556], [116.586623, 39.935715], [116.587509, 39.93587], [116.588395, 39.936025], [116.589281, 39.93618], [116.590167, 39.936335], [116.591053, 39.93649], [116.591939, 39.936645], [116.592825, 39.9368], [116.593711, 39.936955], [116.594597, 39.93711], [116.595483, 39.937265], [116.596369, 39.93742], [116.597255, 39.937575],

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值