In [ ]:
import ipyleaflet 
import json 
import pandas as pd
from ipywidgets import link, FloatSlider
from branca.colormap import linear

geo_json_data = json.load(open('us-states.json')) 
m = ipyleaflet.Map(center = (43,-100), zoom = 4)
unemployment = pd.read_csv('US_Unemployment_Oct2012.csv')

In [ ]:
unemployment =  dict(zip(unemployment['State'].tolist(), unemployment['Unemployment'].tolist()))

In [ ]:
layer = ipyleaflet.Choropleth(
    geo_data=geo_json_data,
    choro_data=unemployment,
    colormap=linear.YlOrRd_04, 
    border_color='black',
    style={'fillOpacity': 0.8, 'dashArray': '5, 5'}
)

In [ ]:
m.add_layer(layer)
m

In [ ]:
slider = FloatSlider(min=layer.value_min, max=layer.value_max, continuous_update=False)
slider.value = layer.value_min
link((slider, 'value'), (layer, 'value_min'))
slider

In [ ]:
linear.YlOrBr_04.to_step(10)

In [ ]:
linear.RdBu_11

In [ ]:
linear.GnBu_09

In [ ]:
layer.colormap = linear.RdBu_11

In [ ]:
layer.border_color = 'white'

In [ ]:
from ipywidgets import Text, HTML
from ipyleaflet import WidgetControl, GeoJSON 


html = HTML('''
    <h4> Name </h4>
    Hover over a state
''')
html.layout.margin = '0px 10px 10px 10px'
control = WidgetControl(widget=html, position='topright')
m.add_control(control)

def update_html(feature, id, **kwargs):
    html.value = '''
        State name:  
        <b>{}\n</b>
        {} 
    '''.format(id, feature['properties']['name'])

layer.on_hover(update_html)

In [ ]:


In [ ]: