In [1]:
from __future__ import print_function
In [2]:
from ipyleaflet import *
In [3]:
m = Map(center=(52, 10), zoom=8, basemap=basemaps.Hydda.Full)
m
In [4]:
strata_all = basemap_to_tiles(basemaps.Strava.All)
m.add_layer(strata_all)
In [5]:
# mouse interaction handling

from ipywidgets import Label

label = Label()
display(label)

def handle_interaction(**kwargs):
    if kwargs.get('type') == 'mousemove':
        label.value = str(kwargs.get('coordinates'))

m.on_interaction(handle_interaction)
In [6]:
strata_water = basemap_to_tiles(basemaps.Strava.Water)
m.substitute_layer(strata_all, strata_water)
In [7]:
# Adding an overlay layer
import json

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.5
    }
geo = GeoJSON(data=data, hover_style={'fillColor': 'red'}, name='Countries')
m.add_layer(geo)
In [8]:
# Adding the control
m.add_control(LayersControl())
In [9]:
# Creating two maps side by side
import ipywidgets
 
ipywidgets.HBox([m, Map(center=[43.6, 1.44], zoom=10)])