Here api 如何使用Here Map JS绘制车辆图标移动动画以及经过的坐标
我需要显示动画和路线。我可以通过计算路线休息电话获得形状信息。希望使用形状坐标绘制循环中从起点到终点移动的车辆动画。如何在HTML页面中使用Java脚本模块在此处实现相同的映射 我尝试了下面URI中列出的信息,但它看起来与我无关Here api 如何使用Here Map JS绘制车辆图标移动动画以及经过的坐标,here-api,here-maps-rest,Here Api,Here Maps Rest,我需要显示动画和路线。我可以通过计算路线休息电话获得形状信息。希望使用形状坐标绘制循环中从起点到终点移动的车辆动画。如何在HTML页面中使用Java脚本模块在此处实现相同的映射 我尝试了下面URI中列出的信息,但它看起来与我无关 此方法将为您指明正确的方向。另请参见以下示例:tcs.ext.here.com/examples/v3/geofinging var Walker = function (marker /*H.map.Marker*/, path /*H.map.Polyline.ge
此方法将为您指明正确的方向。另请参见以下示例:tcs.ext.here.com/examples/v3/geofinging
var Walker = function (marker /*H.map.Marker*/, path /*H.map.Polyline.getStrip()*/) {
this.path = path;
this.marker = marker;
this.idx = 0;
this.dir = -1;
this.isWalking = false;
var that = this;
this.walk = function () {
// Get the next coordinate from the route and set the marker to this coordinate
var coord = path.extractPoint(that.idx);
marker.setPosition(coord);
// If we get to the end of the route reverse direction
if (!that.idx || that.idx === path.getPointCount() - 1) {
that.dir *= -1;
}
that.idx += that.dir;
/* Recursively call this function with time that depends on the distance to the next point
* which makes the marker move in similar random fashion
*/
// that.timeout = setTimeout(that.walk, Math.round(coord.distance(path.extractPoint(that.idx)) * 2.5));
that.timeout = setTimeout(that.walk, 200);
that.isWalking = true;
var pixelcoord = map.geoToScreen(coord),
objects = map.getObjectsAt(pixelcoord.x, pixelcoord.y),
covers = false,
log = document.getElementById("log");
for (var object in objects) {
if (objects[object] === this.circle)
{
log.innerHTML += "Object is in circle geofence <br>";
this.circle.setStyle({fillColor: 'rgba(255, 0, 0, 0.5'});
covers = true;
}
else if(objects[object] === this.polyline)
{
log.innerHTML += "Object is in route geofence <br>";
this.polyline.setStyle({strokeColor: 'rgba(255, 0, 0, 0.5', lineWidth: 8});
covers = true;
}
else if(objects[object] === this.polygon)
{
log.innerHTML += "Object is in polygon geofence <br>";
this.polygon.setStyle({strokeColor: 'rgba(255, 0, 0, 0.5', lineWidth: 8});
covers = true;
}
else if(objects[object] === this.isoline)
{
log.innerHTML += "Object is in isoline geofence <br>";
this.isoline.setStyle({strokeColor: 'rgba(255, 0, 0, 0.5', lineWidth: 8});
covers = true;
}
if(covers)
break;
}
if(!covers && (this.circle !== undefined || this.polyline !== undefined || this.isoline !== undefined || this.polygon !== undefined))
{
log.innerHTML += "Object is not in geofence <br>";
this.circle.setStyle({fillColor: 'rgba(255, 255, 255, 0.5'});
this.polyline.setStyle({strokeColor: 'rgba(0,0,0,0.4)', lineWidth: 8});
this.polygon.setStyle({strokeColor: "#f00", lineWidth: 1});
this.isoline.setStyle({strokeColor: "#f00", lineWidth: 1});
}
log.scrollTop = log.scrollHeight;
};
this.stop = function () {
clearTimeout(that.timeout);
this.isWalking = false;
};
};
var Walker=function(marker/*H.map.marker*/,path/*H.map.Polyline.getStrip()*/){
this.path=path;
this.marker=标记;
这个值为0.idx=0;
this.dir=-1;
this.isWalking=false;
var=这个;
this.walk=函数(){
//从管线获取下一个坐标,并将标记设置为此坐标
var coord=path.extractPoint(即.idx);
标记器。设置位置(坐标);
//如果我们走到路的尽头,就朝相反的方向走
如果(!that.idx | | that.idx===path.getPointCount()-1){
即:dir*=-1;
}
that.idx+=that.dir;
/*递归调用此函数的时间取决于到下一点的距离
*这使得标记以类似的随机方式移动
*/
//that.timeout=setTimeout(that.walk,Math.round(coord.distance(path.extractPoint(that.idx))*2.5));
that.timeout=setTimeout(that.walk,200);
那是真的;
var pixelcoord=map.geoToScreen(坐标),
objects=map.getObjectsAt(pixelcoord.x,pixelcoord.y),
封面=假,
log=document.getElementById(“日志”);
for(对象中的变量对象){
if(对象[对象]==此.circle)
{
log.innerHTML+=“对象位于圆形地理围栏中
”;
this.circle.setStyle({fillColor:'rgba(255,0,0,0.5'});
封面=真实;
}
else if(对象[对象]==此.polyline)
{
log.innerHTML+=“对象位于路由地理围栏中
”;
setStyle({strokeColor:'rgba(255,0,0,0.5',线宽:8});
封面=真实;
}
else if(对象[对象]==此.polygon)
{
log.innerHTML+=“对象位于多边形地理围栏中
”;
this.polygon.setStyle({strokeColor:'rgba(255,0,0.5',线宽:8});
封面=真实;
}
else if(对象[对象]==此.isoline)
{
log.innerHTML+=“对象位于等值线地理围栏中
”;
setStyle({strokeColor:'rgba(255,0,0,0.5',线宽:8});
封面=真实;
}
如有(封面)
打破
}
如果(!cover&&(this.circle!==未定义的| | this.polyline!==未定义的| | this.isoline!==未定义的| | this.polygon!==未定义))
{
log.innerHTML+=“对象不在地理围栏中
”;
this.circle.setStyle({fillColor:'rgba(255,255,255,0.5'});
this.polyline.setStyle({strokeColor:'rgba(0,0,0.4'),线宽:8});
this.polygon.setStyle({strokeColor:#f00',线宽:1});
this.isoline.setStyle({strokeColor:#f00',线宽:1});
}
log.scrollTop=log.scrollHeight;
};
this.stop=函数(){
clearTimeout(即.timeout);
this.isWalking=false;
};
};