In [ ]:
from ipyleaflet import Map, GeoData, basemaps, LayersControl
import geopandas
import json
countries = geopandas.read_file(geopandas.datasets.get_path('naturalearth_lowres'))
rivers = geopandas.read_file("https://www.naturalearthdata.com/http//www.naturalearthdata.com/download/10m/physical/ne_10m_rivers_lake_centerlines.zip")
m = Map(center=(28.6019917,70.9121356), zoom = 3, basemap= basemaps.Esri.WorldTopoMap)
geo_data = GeoData(geo_dataframe = countries,
style={'color': 'black', 'fillColor': '#366370', 'opacity':0.05, 'weight':1.9, 'dashArray':'2', 'fillOpacity':0.6},
hover_style={'fillColor': '#b08a3e' , 'fillOpacity': 0.9},
name = 'Countries')
m.add_layer(geo_data)
m
In [ ]:
from ipywidgets import Text, HTML
from ipyleaflet import WidgetControl, GeoJSON
html = HTML('''
<h4> population density</h4>
Hover over a state
''')
html.layout.margin = '0px 20px 20px 20px'
control = WidgetControl(widget=html, position='topright')
m.add_control(control)
In [ ]:
def update_html(feature, **kwargs):
html.value = '''
<h5>Population density</h5>
<h5><b>{}</b></h5>
{} people
<h5><b> Continent : {} </b></h5>
<h15> GDP : {} </h15>
'''.format(feature['properties']['name'],
feature['properties']['pop_est'],
feature['properties']['continent'],
feature['properties']['gdp_md_est'])
geo_data.on_hover(update_html)
In [ ]:
from ipyleaflet import FullScreenControl, LayersControl
m.add_control(FullScreenControl())
In [ ]: