高德地图关于轨迹回放,一大堆的代码真正的重点就是能有图片动的就是pathSimplifierIns.createPathNavigator(); var navg1 = pathSimplifierIns.createPathNavigator(1, {
loop: false,//控制循环
speed: 1000000,
pathNavigatorStyle: {
width: 24,
height: 24,
//使用图片
content: PathSimplifier.Render.Canvas.getImageContent('./imgs/plane.png', onload, onerror),
strokeStyle: null,
fillStyle: null,
//经过路径的样式
pathLinePassedStyle: {
lineWidth: 6,
strokeStyle: 'black',
dirArrowStyle: {
stepSpace: 15,
strokeStyle: 'red'
}
}
}
});
navg1.start();、
speed: 1000000,
pathNavigatorStyle: {
width: 24,
height: 24,
//使用图片
content: PathSimplifier.Render.Canvas.getImageContent('./imgs/plane.png', onload, onerror),
strokeStyle: null,
fillStyle: null,
//经过路径的样式
pathLinePassedStyle: {
lineWidth: 6,
strokeStyle: 'black',
dirArrowStyle: {
stepSpace: 15,
strokeStyle: 'red'
}
}
}
});
navg1.start();
一般的轨迹线
var map = new AMap.Map('container', {
zoom: 4
});
//加载PathSimplifier,loadUI的路径参数为模块名中 'ui/' 之后的部分
AMapUI.load(['ui/misc/PathSimplifier'], function(PathSimplifier) {
if (!PathSimplifier.supportCanvas) {
alert('当前环境不支持 Canvas!');
return;
}
var pathSimplifierIns = new PathSimplifier({
zIndex: 100,
map: map, //所属的地图实例
getPath: function(pathData, pathIndex) {
//返回轨迹数据中的节点信息,[AMap.LngLat, AMap.LngLat...] 或者 [[lng,lat],[lng,lat]...]
return pathData.path;
},
getHoverTitle: function(pathData, pathIndex, pointIndex) {
//返回鼠标悬停时显示的信息
if (pointIndex >= 0) {
//鼠标悬停在某个轨迹节点上
return pathData.name + ',点:' + pointIndex + '/' + pathData.path.length;
}
//鼠标悬停在节点之间的连线上
return pathData.name + ',点数量' + pathData.path.length;
},
renderOptions: {
//轨迹线的样式
pathLineStyle: {
strokeStyle: 'red',
lineWidth: 6,
dirArrowStyle: true
}
}
});
//这里构建两条简单的轨迹,仅作示例
pathSimplifierIns.setData([{
name: '轨迹1',
path: [
[100.340417, 27.376994],
[108.426354, 37.827452],
[113.392174, 31.208439],
[124.905846, 42.232876]
]
}, {
name: '大地线',
//创建一条包括500个插值点的大地线
path: PathSimplifier.getGeodesicPath([116.405289, 39.904987], [87.61792, 43.793308], 500)
}]);