I have a large variety of KML files in our library.
Most run over a fairly small area (1-3km square) but many are over much larger areas.
Here’s an example of one of the large area KML files presented on our webpage via Cesium. You can’t see the track when the zoom is finished because we are zoomed too far in:
http://www.ka72.com/Track/t/153938
Here’s an example of a smaller area KML file. This one looks fine when viewed presently:
http://www.ka72.com/Track/t/154427
Here’s part of my code from the page:
var terrainProvider = new Cesium.CesiumTerrainProvider({
url: ‘//assets.agi.com/stk-terrain/world’,
requestWaterMask: false
});
viewer.terrainProvider = terrainProvider;
viewer.dataSources.add(datasource.load(‘http://www.ka72.com/DesktopModules/ka72/TrackDetails/kml.asmx/GetFile?tid=153938’)).then(function(datasource) {
viewer.clock.shouldAnimate = false;
viewer.clock.multiplier = 30;
viewer.flyTo(datasource, { duration: 4.0, offset: { heading: 0, pitch: Cesium.Math.toRadians(-45), range: 3000 } }).then(function() {
viewer.clock.clockRange = Cesium.ClockRange.CLAMPED;
viewer.clock.shouldAnimate = true;
}
);
});
As you can see I am using a range of 3000 for the final view, but I’d rather the widget zoomed to the extent of the actual KML file.
The files all consist of:
a gx:track element that defines the whole of the track and includes times for replay purposes.
Several elements that define specific subfeatures of the track.
Previously I had a KML file with only LineString elements, and Cesium seemed to be able to zoom to the extents of that fine, but I can’t get it to work with a gx:track element.
You can obtain the raw KML files for each of the samples above from these links:
http://www.ka72.com/DesktopModules/ka72/TrackDetails/kml.asmx/GetFile?tid=153938
http://www.ka72.com/DesktopModules/ka72/TrackDetails/kml.asmx/GetFile?tid=154427
Dylan.