Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def __init__(self, map=None, layer_controller_list=None, position_controller=None):
if map is None:
map = Map()
map.add_control(ipyleaflet.FullScreenControl())
if layer_controller_list is None:
from .layer_controller import LayerControllerList
layer_controller_list = LayerControllerList(map)
if position_controller is None:
position_controller = PositionController(map)
self.map = map
self.controller_list = layer_controller_list
self.position_controller = position_controller
def on_clear():
for layer in self.map.layers:
try:
layer.forget_errors()
if dst is None:
center = kw.pop('center', None)
zoom = kw.pop('zoom', None)
if center is None:
center = (bbox.bottom + bbox.top)*0.5, (bbox.right + bbox.left)*0.5
if zoom is None:
zoom = zoom_from_bbox(bbox)
height = kw.pop('height', '600px')
width = kw.pop('width', None)
m = Map(center=center, zoom=zoom, **kw)
m.layout.height = height
m.layout.width = width
m.add_control(FullScreenControl())
m.add_control(LayersControl())
else:
m = dst
gg = GeoJSON(data={'type': 'FeatureCollection',
'features': polygons},
style=style,
hover_style={'color': 'tomato'},
name=layer_name)
m.add_layer(gg)
if dst is None:
return m
else:
return gg
draw.circlemarker = {}
shape_opts = {"fillColor": "#fca45d",
"color": "#000000",
"fillOpacity": 0.1}
draw.rectangle = {"shapeOptions": shape_opts,
"metric": ["km", "m"]}
poly_opts = {"shapeOptions": dict(**shape_opts)}
poly_opts["shapeOptions"]["original"] = dict(**shape_opts)
poly_opts["shapeOptions"]["editing"] = dict(**shape_opts)
draw.polygon = poly_opts
draw.edit = True
draw.remove = True
m.add_control(draw)
m.add_control(FullScreenControl())
def on_done(btn):
state.done = True
btn_done.disabled = True
m.remove_control(draw)
for w in widgets:
m.remove_control(w)
def bounds_handler(event):
bounds = event['new']
render_bounds(bounds)
(lat1, lon1), (lat2, lon2) = bounds
state.bounds = dict(lat=(lat1, lat2),
lon=(lon1, lon2))
def on_draw(event):
time,
zoom=None,
center=None,
height=None,
width=None):
from ipywidgets import widgets as w
import ipyleaflet as L
pp = {'zoom': zoom or 1}
if center is not None:
pp['center'] = center
m = L.Map(**pp,
scroll_wheel_zoom=True)
m.add_control(L.FullScreenControl())
prod_select = w.Dropdown(options=product_names, layout=w.Layout(
flex='0 1 auto',
width='10em',
))
date_txt = w.Text(value=time, layout=w.Layout(
flex='0 1 auto',
width='6em',
))
info_lbl = w.Label(value='', layout=w.Layout(
flex='1 0 auto',
# border='1px solid white',
))
btn_bwd = w.Button(icon='step-backward', layout=w.Layout(
def show(self, tabs=True, layer_control=True, draw_control=False,
fullscreen=True):
""" Show the Map on the Notebook """
if not self.is_shown:
if layer_control:
# Layers Control
lc = ipyleaflet.LayersControl()
self.add_control(lc)
if draw_control:
# Draw Control
dc = ipyleaflet.DrawControl(edit=False)
dc.on_draw(self.handle_draw)
self.add_control(dc)
if fullscreen:
# Control
full_control = ipyleaflet.FullScreenControl()
self.add_control(full_control)
if tabs:
display(self, self.tab_widget)
else:
display(self)
else:
# if len(tabs) > 0:
if tabs:
display(self, self.tab_widget)
else:
display(self)
self.is_shown = True
# Start with crosshair cursor
self.default_style = {'cursor': 'crosshair'}
def show(self, tabs=True, layer_control=True, draw_control=False,
fullscreen=True):
""" Show the Map on the Notebook """
if not self.is_shown:
if layer_control:
# Layers Control
lc = ipyleaflet.LayersControl()
self.add_control(lc)
if draw_control:
# Draw Control
dc = ipyleaflet.DrawControl(edit=False)
dc.on_draw(self.handle_draw)
self.add_control(dc)
if fullscreen:
# Control
full_control = ipyleaflet.FullScreenControl()
self.add_control(full_control)
if tabs:
display(self, self.tab_widget)
else:
display(self)
else:
if tabs:
display(self, self.tab_widget)
else:
display(self)
self.is_shown = True
# Start with crosshair cursor
self.default_style = {'cursor': 'crosshair'}