Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Flyto or zoomto to an entity or entities #70

Open
CMCDragonkai opened this issue Oct 17, 2016 · 5 comments
Open

Flyto or zoomto to an entity or entities #70

CMCDragonkai opened this issue Oct 17, 2016 · 5 comments

Comments

@CMCDragonkai
Copy link

On cesium you can normally add an entity and fly to that entity:

            var wyoming = viewer.entities.add({
                name: 'Wyoming',
                // polygon :: Cesium.PolygonGraphics
                polygon: {
                    // polygon longitude and latitude (not totally accurate)
                    hierarchy: Cesium.Cartesian3.fromDegreesArray([
                        -109.080842, 45.002073,
                        -105.91517,  45.002073,
                        -104.058488, 44.996596,
                        -104.053011, 43.002989,
                        -104.053011, 41.003906,
                        -105.728954, 40.998429,
                        -107.919731, 41.003906,
                        -109.04798,  40.998429,
                        -111.047063, 40.998429,
                        -111.047063, 42.000709,
                        -111.047063, 44.476286,
                        -111.05254,  45.002073
                    ]),
                    material: Cesium.Color.RED.withAlpha(0.5)
                }
            });

            viewer.flyTo(wyoming).then(function(result){
                if (result) {
                    viewer.selectedEntity = wyoming;
                }
            });

I just tried this with an entity I added via ob = v.dataSources.add() but I wasn't able run v.camera.flyTo(ob), it didn't fly anywhere.

How can this be done? Also I'm a bit confused as to how Cesium's Javascript API maps to the Python object API, some things are placed in different areas.

@CMCDragonkai CMCDragonkai changed the title Flyto to an entity Flyto or zoomto to an entity or entities Oct 17, 2016
@CMCDragonkai
Copy link
Author

Furthermore, how do you set the default position of the camera? This didn't work: http://stackoverflow.com/questions/28709007/how-to-set-the-default-view-location-cesium-1-6

@sinhrks
Copy link
Owner

sinhrks commented Oct 23, 2016

Thx for the report. Because simple JavaScript call v.camera.flyTo(v.dataSources) doesn't work, current impl needs to be fixed. Will consider better soln.

@CMCDragonkai
Copy link
Author

Any news on this?

1 similar comment
@callmeYe
Copy link

Any news on this?

@fc
Copy link

fc commented May 27, 2020

This might help someone since I also had trouble using zoomTo on an entity that had just been added.
https://cesium.com/docs/cesiumjs-ref-doc/Rectangle.html#.fromCartesianArray

    const arrayOfPositions = /* create array of Cesium.Cartesian3 here */;
    const destination = Cesium.Rectangle.fromCartesianArray(arrayOfPositions);
    this.viewer.camera.setView({
      destination,
    });
    this.viewer.camera.zoomOut(); // maybe not needed but adds a helpful buffer for my purposes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants