How we can fly to more then one entity using cesium came

I want to zoom on the more then 1 entity Please suggest me and tall me how can i do it.

You can zoomTo or flyTo an array of entities using the Viewer functions.

viewer.zoomTo([entity1, entity2]);

See the Camera Controls section of the Visualizing Spatial Data tutorial for more details.

Neither zoomTo nor flyTo are working for me when I provide entities. I need to manually produce my own latlon array from the entities.

If for example I execute this from the JS console:
viewer.zoomTo(viewer.entities)

I just get:
Object { then: e(), resolve: r(), reject: n(), progress: s(), promise: Object, resolver: Object }

and no movement/change in the view. Doesn’t work if I provide any of my known entities either.

I am using v1.13.

That return value is expected because zoomTo returns a promise that let’s you know when the zoom is complete (or fails). If it’s generating an error orotherwise failing, you can get more information with the below code:

viewer.zoomTo(viewer.entities)

.then(function(result){

if(!result) {

console.log(‘Zoom was canceled or entities not in scene’);

}

});

.otherwise(

function(error) {

console.log(error);

});

Here’s a complete working example that zooms to 3 entities: http://cesiumjs.org/Cesium/Apps/Sandcastle/index.html?src=Box.html&label=Geometries

If you are still having problems, can you please post post a small complete example that shows your code, something we can reproduce using Sandcastle.

Thanks

There was a small typo in my code (extra :wink: The working code is:

viewer.zoomTo(viewer.entities)
.then(function (result) {
if (!result) {
console.log(‘Zoom was canceled or entities not in scene’);
}
})
.otherwise(function (error) {
console.log(error);
});

I’ll try to produce a small example. Right now all my project is in:

http://davidrlowe.github.io/pic/

I want to zoom in to a PolylineCollection called lines this is what I get in the console when I type lines:

Object { modelMatrix: Object[16], _modelMatrix: Object[16], debugShowBoundingVolume: false, _opaqueRS: Object, _translucentRS: Object, _colorCommands: Array[1], _pickCommands: Array[1], _polylinesUpdated: false, _polylinesRemoved: false, _createVertexArray: false, 11 more… }

This is what I get when I type your code with lines as input:

viewer.zoomTo(lines)
.then(function (result) {
if (!result) {

        console.log('Zoom was canceled or entities not in scene');
    }
})
.otherwise(function (error) {
    console.log(error);
});

``

results in:

Object { then: e() }
Zoom was canceled or entities not in scene

``

No movement.

I see the confusion. PolylineCollection is not part of the Entity API, it’s part of the older Primitive API. I would suggest against using PolylineCollection and instead use the Entity API instead. Check out the full Visualizing Spatial Data tutorial for details

see this thread for my current situation: https://groups.google.com/forum/#!topic/cesium-dev/rRlnJ63Zo0U

Thanks Matthew you are angle :slight_smile:

There is some way to do this but with 3d tiles.
zoom to several buildings that have the property show = true for example

thaks

For doing this with 3D Tiles, see the discussion here:

https://groups.google.com/d/msg/cesium-dev/Xsbvl3Q_WdQ/M_EZbLEbFQAJ