cesiumpy
cesiumpy copied to clipboard
Flyto or zoomto to an entity or entities
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.
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
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.
Any news on this?
Any news on this?
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