1. A concise explanation of the problem you're experiencing.
Coordinates of entity with entity position with Cesium.Cartesian3.fromDegrees(lat,long,height) from WGS84 show wrong place...
2. A minimal code example. If you've found a bug, this helps us reproduce and repair it.
window.setInterval("flightradar('D-AEWS')",100);
var res4=0
var res5=0
var res6=0
var res7=0
var res8=0
var timer=0
'use strict';
//Sandcastle_Begin
var viewer = new Cesium.Viewer('cesiumContainer', {
infoBox : false,
selectionIndicator : false,
shadows : true,
shouldAnimate : true,
terrainProvider: Cesium.createWorldTerrain({requestWaterMask: true}),
scene3DOnly: true,
selectionIndicator: false,
baseLayerPicker: false
});
var layers = viewer.scene.imageryLayers;
var mapOpenWeatherMaps = layers.addImageryProvider(new Cesium.createOpenStreetMapImageryProvider( {
url: ‘http://tile.openweathermap.org/map/clouds_new’,
fileExtension: ‘png’ + ‘?appid=d56085bd95e53422bbda70c0fea04ae0’
}));
mapOpenWeatherMaps.opacity=0.2
var scene = viewer.scene;
var positions= ;
handler = new Cesium.ScreenSpaceEventHandler(scene.canvas);
handler.setInputAction(function(dbClick){
}, Cesium.ScreenSpaceEventType.LEFT_DOUBLE_CLICK);
function flightradar(registration)
{ timer=timer+1
if(timer>100)
{var date= new Date()
var res
var url = 'http://data-live.flightradar24.com/zones/fcgi/feed.js?reg=!’+registration+’&_=’+date
var doc= new XMLHttpRequest()
doc.onreadystatechange = function(){
if(doc.readyState == XMLHttpRequest.DONE){
res=doc.responseText//JS.data(doc.responseText)
var res1=res.split("[")
var res2=res1[1]
var res3=res2.split(",")
res4=parseFloat(res3[1]) //latitude_value
res5=parseFloat(res3[2]) // longitude_value
res6=parseFloat(res3[3]) // track_value
res7=parseFloat(res3[4])*0.3048 // altitude_value
res8=parseFloat(res3[5]) // speed_value
//console.log(res4+" “+res5+” “+res6+” “+res7+” "+res8)
}
}
doc.open('GET', url, true)
doc.send()
timer=0
}
window.print(res4+" "+res5+" "+res7)
viewer.entities.removeAll();
var vit=res8
var track=res6
var lat=res4
var lon=res5
var radius = 6370640
var speed_ms=vit*0.51444
var distance=speed_ms*0.09
var δ = Number(distance) / radius; // angular distance in radians
var θ = Number(track)*Math.PI/180;
var φ1 = lat*Math.PI/180;
var λ1 = lon*Math.PI/180;
var sinφ1 = Math.sin(φ1), cosφ1 = Math.cos(φ1);
var sinδ = Math.sin(δ), cosδ = Math.cos(δ);
var sinθ = Math.sin(θ), cosθ = Math.cos(θ);
var sinφ2 = sinφ1*cosδ + cosφ1*sinδ*cosθ;
var φ2 = Math.asin(sinφ2);
var y = sinθ * sinδ * cosφ1;
var x = cosδ - sinφ1 * sinφ2;
var λ2 = λ1 + Math.atan2(y, x);
let newLat =φ2*180/Math.PI
let newLong= (λ2*180/Math.PI+540)%360-180
res4=newLat
res5=newLong
var position = Cesium.Cartesian3.fromDegrees(res4, res5, res7);
var heading = Cesium.Math.toRadians(res6);
var pitch = 0;
var roll = 0;
var hpr = new Cesium.HeadingPitchRoll(heading, pitch, roll);
var orientation = Cesium.Transforms.headingPitchRollQuaternion(position, hpr);
var entity = viewer.entities.add({
name : 'Cesium_Air',
position : position,
orientation : orientation,
model : {
uri : '../../../../Apps/SampleData/models/CesiumAir/Cesium_Air.glb',
minimumPixelSize : 128,
maximumScale : 20000
}
});
viewer.trackedEntity = entity;
}
//Sandcastle_End
Sandcastle.finishedLoading();
3. Context. Why do you need to do this? We might know a better way to accomplish your goal.
following aircraft in 3d with flightradar api
4. The Cesium version you're using, your operating system and browser.
cesium 1.51, win10/64, Qt 5.10.1 / 64 / MSVC2015 / WebView