================== Ipyleaflet Example ================== Thebe can display output from ipyleaflet_ Jupyter widgets. This example_ is repurposed from the ipyleaflet documentation and is licensed under the MIT License (MIT). .. _ipyleaflet: https://github.com/jupyter-widgets/ipyleaflet .. _example: https://github.com/jupyter-widgets/ipyleaflet/blob/master/examples/Heatmap.ipynb Setup ===== Be sure to load require.min.js before any of your thebe activation code, it is required for Jupyter widgets to work: .. code-block:: html Configure thebe and load it: .. code-block:: html Create a button to activate thebe: .. code-block:: html Now add code cells between these HTML tags: .. code-block:: html


Example
=======

.. raw:: html

   
   
   

Press the "Activate" button below to connect to a Jupyter server:

.. raw:: html

   
   

Here we will display a basic leaflet map:

.. raw:: html

   
   from ipyleaflet import Map, Heatmap
   from random import uniform
   import time

   def create_random_data(length):
       "Return a list of some random lat/lon/value triples."
       return [[uniform(-80, 80),
            uniform(-180, 180),
            uniform(0, 1000)] for i in range(length)]

   m = Map(center=[0, 0], zoom=2)
   m
   
Now we add a heatmap: .. raw:: html
   heat = Heatmap(locations=create_random_data(1000), radius=20, blur=10)
   m.add_layer(heat)
   
Finally, we add some animation to our heatmap: .. raw:: html
   for i in range(100):
       heat.locations = create_random_data(1000)
       time.sleep(0.1)