from ipyleaflet import *
import json 
import pandas as pd
from ipywidgets import link, FloatSlider
from branca.colormap import linear

m = Map(layers=(basemap_to_tiles(basemaps.Esri.WorldTopoMap),), center=(52.088889, 5.33), zoom=8)

geo_json_data = json.load(open('nederlandse_gemeenten_met_obs.json')) 
unemployment = json.load(open('PublicLibraryDensityNL.json')) 

density_style={'color': 'red', 'opacity':1, 'weight':1, 'dashArray':'2','fillOpacity':0.0}

layer = Choropleth(
    geo_data=geo_json_data,
    choro_data=unemployment)

layer.style=density_style
layer.colormap=linear.RdYlGn_11 
m.add_layer(layer)

slider = FloatSlider(description='Doorzichtigheid', min=layer.value_min, 
                     max=1.1*layer.value_max, continuous_update=False, orientation='vertical', step=0.25,
                        disabled=False,readout=True, readout_format='.2f',)
slider.value = layer.value_min
link((slider, 'value'), (layer, ))

widget_control1 = WidgetControl(widget=slider, position='topright')
m.add_control(widget_control1)
m
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-21-69f1ad745110> in <module>
     24                         disabled=False,readout=True, readout_format='.2f',)
     25 slider.value = layer.value_min
---> 26 link((slider, 'value'), (layer, layer.style.fillopacity))
     27 
     28 widget_control1 = WidgetControl(widget=slider, position='topright')

AttributeError: 'dict' object has no attribute 'fillopacity'
import ipyleaflet as ipyl
import ipywidgets as ipyw
import json
from ipywidgets import *
from ipyleaflet import *

# Map and label widgets
map = ipyl.Map(center=[53.88, 27.45], zoom=4)

boxlayout=Layout(margin='0 0 0 0px', 
                 border='2px dashed red', 
                 width='auto')

label = HTML()

box=Box([label], layout=boxlayout)

#print(layer.style.keys)

# geojson layer with hover handler
with open('europe_110.geo.json') as f:
    data = json.load(f)

for feature in data['features']:
    feature['properties']['style'] = {
        'color': 'grey',
        'weight': 1,
        'fillColor': 'grey',
        'fillOpacity': 0.9
    }
layer = GeoJSON(data=data, hover_style={'fillColor': 'red'})

def hover_handler(event=None, id=None, properties=None):
    label.value="<b>Land:</b> "+ properties['geounit']+\
    "<br/><b>Provincie:</b> "+ properties['subregion']+\
    "<br/><b>Inwoners:</b> "+ str('{:,}'.format(properties['pop_est']).replace(',', '.'))+\
    "<br/><b>Inkomen:</b> "+ str('{:,}'.format(properties['gdp_md_est']).replace(',', '.'))
    
   

layer.on_hover(hover_handler)

map.add_layer(layer)

widget_control = WidgetControl(widget=box, position='bottomright', min_height=115, max_height=115, 
                               min_width=250)
map.add_control(widget_control)

map
minimap = Map(
    zoom_control=False, attribution_control=False, 
    zoom=5, center=[53.88, 27.45], basemap=basemaps.Stamen.Terrain
)
minimap.layout.width = '150px'
minimap.layout.height = '150px'
link((minimap, 'center'), (map, 'center'))
link((minimap, 'zoom'), (map, 'zoom'))

minimap_control = WidgetControl(widget=minimap, position='topright')
map.add_control(minimap_control)
from ipyleaflet import Map, basemaps, basemap_to_tiles, CircleMarker

watercolor = basemap_to_tiles(basemaps.Stamen.Watercolor)

m = Map(layers=(watercolor, ), center=(53, 354), zoom=5)

circle_marker = CircleMarker()
circle_marker.location = (54, 360)
circle_marker.radius = 5
circle_marker.color = "red"
circle_marker.fill_color = "red"

m.add_layer(circle_marker)

m
from ipywidgets import HTML

from ipyleaflet import Map, Marker, Popup

center = (52.204793, 360.121558)

m = Map(center=center, zoom=9, close_popup_on_click=False)

marker = Marker(location=(52.1, 359.9))
m.add_layer(marker)

message1 = HTML()
message2 = HTML()
message1.value = "Try clicking the marker!"
message2.value = "Hello <b>Wh /hg ';ghl ';fg gf fg g ghl'; lghl  gf gf gf fg fg fg gf g fg gfg fg f';glh orld</b><br/>dfdsfdsf fds fdsf "
message2.description =  "<img src='https://upload.wikimedia.org/wikipedia/commons/thumb/d/d8/Bibliotheek_Boxtel_P1040903.JPG/180px-Bibliotheek_Boxtel_P1040903.JPG'/>"
  

# Popup with a given location on the map:
popup2 = Popup(
    child=message2,
    close_button=False,
    auto_close=False,
    close_on_escape_key=False,
    max_width=1300
)
m.add_layer(popup2)
# Popup associated to a layer
marker.popup = message2


m
from ipyleaflet import *
import ipywidgets as w
from ipywidgets import HTML

m = Map(center = (46,0), zoom = 3)

slider = w.FloatLogSlider(max=10,value = 2 )
marker = Marker(location = (46,0))
marker.popup = slider     # popup attribute  
m.add_layer(marker)

#marker.popup = HTML(" hello") 
m