Hi,
I am creating polylines and updating their position in real time.
for some reason, I can see all the created polylines in my viewer.entities list, but on the map only 1 line is showing.
All line in the list have show value of true.
here is the line creating function and the line update function:
function createLine(localEsr,color){
var worldLocation = localEsr.getLocation();
var x = worldLocation[0]-shipCoords[0];
var y = worldLocation[1]-shipCoords[1];
var z = worldLocation[2]-shipCoords[2];
var x1 = shipCoords[0]+x*2;
var y1 = shipCoords[1]+y*2;
var z1 = shipCoords[2]+z*2;
var geodetic = mak.globalEllipsoid.geocentric_to_geodetic(x1, y1, z1);
geodetic[0] *= 180.0 / Math.PI;
geodetic[1] *= 180.0 / Math.PI;
geodetic[2] *= 180.0 / Math.PI;
var shipGeodetic = mak.globalEllipsoid.geocentric_to_geodetic(shipCoords[0], shipCoords[1], shipCoords[2]);
shipGeodetic[0] *= 180.0 / Math.PI;
shipGeodetic[1] *= 180.0 / Math.PI;
shipGeodetic[2] *= 180.0 / Math.PI;
/* var d = Math.sqrt(Math.pow(geodetic[1]-shipCoords[1],2)+ Math.pow(geodetic[0]-shipCoords[0],2 ));
var m = (geodetic[0]-shipCoords[0])/(geodetic[1]-shipCoords[1]);
var n = shipCoords[0]-m*(shipCoords[1]);
var x = geodetic[1]+d/Math.sqrt(1+m);
var y = m*x +n;*/
var colorRec;
if(color =='blue'){
colorRec = Cesium.Color.BLUE;
}
else if(color =='green')
{
colorRec = Cesium.Color.GREEN;
}
else if(color =='red')
{
colorRec = Cesium.Color.RED;
}
else if(color =='purple')
{
colorRec = Cesium.Color.PURPLE;
}
var marking;
marking = 'polyline_'+ localEsr.marking;
if(!(isNaN(shipGeodetic[0]) && isNaN(geodetic[0]))){
myviewer.entities.add({
name : marking,
polyline : {
show: true,
positions : Cesium.Cartesian3.fromDegreesArray([shipGeodetic[1],shipGeodetic[0], geodetic[1],geodetic[0]]),
width : 2,
material : colorRec
}
});
}
};
function updateLine(cesiumEntity, localEsr){
var worldLocation = localEsr.getLocation();
var x = worldLocation[0]-shipCoords[0];
var y = worldLocation[1]-shipCoords[1];
var z = worldLocation[2]-shipCoords[2];
var x1 = shipCoords[0]+x*3;
var y1 = shipCoords[1]+y*3;
var z1 = shipCoords[2]+z*3;
var geodetic = mak.globalEllipsoid.geocentric_to_geodetic(x1, y1, z1);
geodetic[0] *= 180.0 / Math.PI;
geodetic[1] *= 180.0 / Math.PI;
geodetic[2] *= 180.0 / Math.PI;
var shipGeodetic = mak.globalEllipsoid.geocentric_to_geodetic(shipCoords[0], shipCoords[1], shipCoords[2]);
shipGeodetic[0] *= 180.0 / Math.PI;
shipGeodetic[1] *= 180.0 / Math.PI;
shipGeodetic[2] *= 180.0 / Math.PI;
cesiumEntity.polyline.positions = Cesium.Cartesian3.fromDegreesArray([shipGeodetic[1],shipGeodetic[0], geodetic[1],geodetic[0]]);
};
Any idea?
Thanks,
Kfir.