I’ve been struggling with this for some days.
I want to make an animation that follows a route/path, like the one included in the sandcastle examples “KML.html bikeRide”.
My problem is that no matter what I do, the flyTo method ignores the altitudes from my kml file, HOWEVER, when I use the coordinates from the sandcastle example, altitudes are not being ingored. When I use my kml file the animation happens on ground level, even if every coordinate has an altitude of 5000 or 15000.
It’s very frustrating since both kml’s are practically the same, only the timeline and coordinates tags are different.
This is the kml info from the bikeRide example:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<visibility>1</visibility>
<name>my track</name>
<Style id="track">
<LineStyle><color>ffffff00</color><width>0</width></LineStyle>
<IconStyle>
<scale>0</scale>
<Icon></Icon>
</IconStyle>
</Style>
<Placemark id="tour">
<name></name>
<description>description</description>
<styleUrl>#track</styleUrl>
<gx:Track>
<altitudeMode>clampToGround</altitudeMode>
<when>2013-07-25T19:33:58.000Z</when>
<gx:coord>-75.300238 40.109584 3000</gx:coord>
<when>2013-07-25T19:33:59.000Z</when>
<gx:coord>-75.300234 40.109597 3000</gx:coord>
<when>2013-07-25T19:34:00.000Z</when>
<gx:coord>-75.300214 40.109641 3000</gx:coord>
<when>2013-07-25T19:34:09.000Z</when>
<gx:coord>-75.300233 40.109603 3000</gx:coord>
<when>2013-07-25T19:34:10.000Z</when>
<gx:coord>-75.30025 40.109586 3000</gx:coord>
<when>2013-07-25T19:34:42.000Z</when>
...
And this is my kml file info:
<?xml version="1.0" encoding="UTF-8"?>
<kml xmlns="http://www.opengis.net/kml/2.2"
xmlns:gx="http://www.google.com/kml/ext/2.2"
xmlns:atom="http://www.w3.org/2005/Atom">
<Document>
<visibility>1</visibility>
<name>my track</name>
<Style id="track">
<LineStyle><color>ffff00ff</color><width>2</width></LineStyle>
<IconStyle>
<scale>0</scale>
<Icon></Icon>
</IconStyle>
</Style>
<Placemark id="tour">
<name></name>
<description>description</description>
<styleUrl>#track</styleUrl>
<gx:Track>
<altitudeMode>clampToGround</altitudeMode>
<when>2013-07-25T19:32:27.000Z</when>
<gx:coord>-116.7939602 32.5433699 13000</gx:coord>
<when>2013-07-25T19:32:37.000Z</when>
<gx:coord>-115.7939602 31.5 13000</gx:coord>
<when>2013-07-25T19:32:48.000Z</when>
<gx:coord>-114.7939602 31 13000</gx:coord>
<when>2013-07-25T19:32:49.000Z</when>
<gx:coord>-113.7939602 30.5 13000</gx:coord>
...
The only difference between these 2 files is that the bikeRide.kml has around 5,200 coordinates/timestamps while mine has only 27.
The code that I’m using, it’s pretty much the same as the one from the examples, I just need to change the kml source in order to test one file or the other, and the viewer.clock.multiplier value: 1 for my kml and 30 for the bikeRide.kml:
document.getElementById("startAnimation").addEventListener("click", function(event) {
viewer.dataSources.add(Cesium.KmlDataSource.load("./kmls/routeAnimation2.kml?grggrger", options)).then(function(dataSource) {
viewer.clock.shouldAnimate = false;
const rider = dataSource.entities.getById("tour");
viewer.flyTo(rider).then(function() {
viewer.trackedEntity = rider;
viewer.selectedEntity = viewer.trackedEntity;
viewer.clock.multiplier = 1;
viewer.clock.shouldAnimate = true;
});
});
});
I really don’t understand why in one case, the altitude is being ignored and in the other case is not.
I also don’t understand why in the documentation, the viewer.flyTo method is described like this:
Cesium.KmlTourFlyTo(target, options), like expecting these 2 parameters, however, in the SandCastle examples is being used like my previous code viewer.flyTo(rider) using 1 parameter only.
All I need is to be able to move the map through some coordinates (longitude, latitude and altitude) so if there’s an easier way to do it, I’ll be glad to know.
I just don’t understand why with one kml the altitude works and with the other doesn’t.
Any help will be really appreciated!!