This is an example notebook to sow how to bind the Cesiumjs with the IPython interactive widget system.
In [ ]:
from CesiumWidget import CesiumWidget
from IPython import display
from czml_example import simple_czml, complex_czml
The code:
from czml_example import simple_czml, complex_czml
Simply import some CZML data for the viewer to display.
Create widget object
In [ ]:
cesiumExample = CesiumWidget(width="100%", enable_lighting=True)
Display the widget:
In [ ]:
cesiumExample
Add some data to the viewer
In [ ]:
cesiumExample.czml = simple_czml
In [ ]:
cesiumExample.czml = complex_czml
Now let's make some interactive widget:
In [ ]:
from __future__ import print_function
from ipywidgets import interact, interactive, fixed
from ipywidgets import widgets
keys
In [ ]:
myczml = {'simple_czml':simple_czml, 'complex_czml':complex_czml}
In [ ]:
myplace = {'Eboli, IT':'', 'Woods Hole, MA':'', 'Durham, NH':''}
In [ ]:
import geocoder
import time
for i in myplace.keys():
g = geocoder.google(i)
print(g.latlng)
myplace[i]=g.latlng
In [ ]:
myplace
In [ ]:
@interact(z=(0,20000000), heading=(-180,180), pitch=(-90,90), roll=(-360,360),
Location=('Eboli, IT','Woods Hole, MA','Durham, NH'))
def f(z=1000000, heading=0, pitch=-90, roll=0, Location='Eboli, IT'):
cesiumExample.zoom_to(myplace[Location][1], myplace[Location][0], z, heading, pitch, roll)
@interact(CZML=('simple_czml','complex_czml'))
def c(CZML=None):
cesiumExample.czml = myczml[CZML]
In [ ]:
cesiumExample
In [ ]: