issue with Viewer.flyTo on KML entity

Hi all,

I'm seeing an issue with Viewer.flyTo (also zoomTo) on entities derived from a KML file. To illustrate, here's a Sandcastle example that loads a KML file with a single placemark:

var viewer = new Cesium.Viewer('cesiumContainer');
var options = {
    camera :,
    canvas : viewer.scene.canvas
var zoomTarget;

var kmlFile = "";
var promise = Cesium.KmlDataSource.load(kmlFile, options);
Cesium.when(promise, function(dataSource) {
    zoomTarget = dataSource.entities.values[0];

Sandcastle.addToolbarButton('Fly to Placemark', function() {
}, 'toolbar');

Content of the KML file:

<kml xmlns="">
            My office
            This is the location of my office.

When you click the button to fly to the placemark, the viewer zooms too far ending up below ground. Clicking the button again zooms out to the correct view.

Interestingly, the issue doesn't occur with non-KML entities. In the following example, an entity is created with the same coordinates as the KML placemark above, but in this case, the viewer zooms to the appropriate view on the first button click.

var viewer = new Cesium.Viewer('cesiumContainer');
var options = {
    camera :,
    canvas : viewer.scene.canvas

var pinBuilder = new Cesium.PinBuilder();
var entity = viewer.entities.add({
    position : Cesium.Cartesian3.fromDegrees(-122.087461,37.422069),
    label : {
        text : 'pin',
        verticalOrigin : Cesium.VerticalOrigin.TOP
    billboard : {
        image : pinBuilder.fromColor(Cesium.Color.SALMON, 24).toDataURL(),
        verticalOrigin : Cesium.VerticalOrigin.BOTTOM,

Sandcastle.addToolbarButton('Fly To Entity', function() {
}, 'toolbar');

The difference between the two examples appears to be the initial bounding sphere computed for the entity. For the second example, the center of the bounding sphere is identical to the entity's position. Not so with the KML example -- the z-component in particular is much smaller. After the second button click, the bounding sphere gets recalculated and the center becomes roughly the same.

Is there anything that can be done so users don't have to click twice to zoom to KML features?


Hello Norm,

Thanks for looking into this! I’ve filed an issue on our GitHub for us to look into it:

viewer.flyTo polls to get the bounding sphere for the entity and isn’t supposed to fly to it until the bounding sphere is ready. I’m guessing flyTo is being triggered before the bounding sphere is ready

We have a bug bash coming up in the middle of October, and I’ve tagged this issue for us to look into it then. Of course, we’d gladly accept a contribution if you would like to look into fixing the problem before then =)

Here’s the function in viewer that computes the bounding sphere to fly to:

And here is where the data source display gets the bounding spheres from the entity visualizers:

You can check out our contributors documentation for how to download and build the code base:

Sorry I don’t have any good workarounds.

Thanks again,



This issue has been fixed and will be available in the Cesium 1.27 release available on November 1st.



I believe this is not fixed. I have just tested with original code and all my labels and pins from KML are still underground.
I have posted also to original

So if anyone has a working examle of KML loading and flyTo I would be happy.