How to use the ipyleaflet.Map function in ipyleaflet

To help you get started, we’ve selected a few ipyleaflet examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github vaexio / vaex / packages / vaex-jupyter / vaex / jupyter / viz.py View on Github external
def __init__(self, geo_json, column_names,  **kwargs):
        # self._control = None
        super(VizMapGeoJSONLeaflet, self).__init__(**kwargs)
        self.map = ipyleaflet.Map(center=[40.72866940630964, -73.80228996276857], zoom=10)
        self.control = VizMapGeoJSONLeaflet.Control(self, column_names)
        self.regions_layer = ipyleaflet.LayerGroup()
        # self.index_mapping = {}
        self.output = widgets.Output()
        for i, feature in enumerate(geo_json["features"]):
            if feature["geometry"]["type"] == "Polygon":
                    feature["geometry"]["type"] = "MultiPolygon"
                    feature["geometry"]["coordinates"] = [feature["geometry"]["coordinates"]]
            polygon = ipyleaflet.GeoJSON(data=feature, hover_style={'fillColor': 'red', 'fillOpacity': 0.6})
            self.regions_layer.add_layer(polygon)
            # self.index_mapping[feature['properties'][index_key]] = i
            @self.output.capture()
            # @vaex.jupyter.debounced(DEBOUNCE_SLICE)
            def on_hover(index=i, **properties):
                # index_value = properties[index_key]
                # index = self.index_mapping[index_value]
github opendatacube / odc-tools / libs / ui / odc / ui / _dc_explore.py View on Github external
def _build_ui(self,
                  product_names,
                  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',
github opendatacube / odc-tools / libs / ui / odc / ui / _map.py View on Github external
html_info = HTML(layout=Layout(flex='1 0 20em',
                                   width='20em',
                                   height='3em'))

    def update_info(txt):
        html_info.value = '<pre style="color:grey">' + txt + '</pre>'

    def render_bounds(bounds):
        (lat1, lon1), (lat2, lon2) = bounds
        txt = 'lat: [{:.{n}f}, {:.{n}f}]\nlon: [{:.{n}f}, {:.{n}f}]'.format(
            lat1, lat2, lon1, lon2, n=4)
        update_info(txt)

    if map is None:
        m = Map(**kwargs) if len(kwargs) else Map(zoom=2)
        m.scroll_wheel_zoom = True
        m.layout.height = height
    else:
        m = map
        render_bounds(m.bounds)

    widgets = [
        WidgetControl(widget=btn_done, position='topright'),
        WidgetControl(widget=html_info, position='bottomleft'),
    ]
    for w in widgets:
        m.add_control(w)

    draw = DrawControl()

    draw.circle = {}
github sassoftware / python-esppy / esppy / espapi / visuals.py View on Github external
def __init__(self,visuals,datasource,**kwargs):
        Chart.__init__(self,visuals,datasource,**kwargs)

        self._map = maps.Map()
        self._lat = None
        self._lon = None
        self._markers = {}
        self._colorbar = None

        self._colors = None
        self._colorRange = None

        self._circles = []
        self._polygons = []

        self._icon = None
github gee-community / gee_tools / geetools / ui / ipymap.py View on Github external
getBounds, getZoom, featurePropertiesOutput
from . import maptool, ipytools
import threading
from copy import copy
import traceback
import sys
import ee

ZOOM_SCALES = {
    0: 156543, 1: 78271, 2: 39135, 3: 19567, 4: 9783, 5: 4891, 6: 2445,
    7: 1222, 8: 611, 9: 305, 10: 152, 11: 76, 12: 38, 13: 19, 14: 9, 15: 5,
    16: 2, 17: 1, 18: 0.5, 19: 0.3, 20: 0.15, 21: 0.07, 22: 0.03,
}


class Map(ipyleaflet.Map):
    tab_children_dict = Dict()
    EELayers = Dict()
    def __init__(self, tabs=('Inspector', 'Layers', 'Assets', 'Tasks'),
                 **kwargs):
        # Change defaults
        kwargs.setdefault('center', [0, 0])
        kwargs.setdefault('zoom', 2)
        kwargs.setdefault('scroll_wheel_zoom', True)
        kwargs.setdefault('max_zoom', 22)
        super(Map, self).__init__(**kwargs)
        self.is_shown = False

        # Width and Height
        self.width = kwargs.get('width', None)
        self.height = kwargs.get('height', None)
        self.setDimensions(self.width, self.height)
github fitoprincipe / ipygee / ipygee / map.py View on Github external
from copy import copy
import traceback
from .maptools import *
from .widgets import ErrorAccordion
from .utils import *
import re


ZOOM_SCALES = {
    0: 156543, 1: 78271, 2: 39135, 3: 19567, 4: 9783, 5: 4891, 6: 2445,
    7: 1222, 8: 611, 9: 305, 10: 152, 11: 76, 12: 38, 13: 19, 14: 9, 15: 5,
    16: 2, 17: 1, 18: 0.5, 19: 0.3, 20: 0.15, 21: 0.07, 22: 0.03,
}


class Map(ipyleaflet.Map):
    tab_children_dict = Dict()
    EELayers = Dict()

    def __init__(self, tabs=('Inspector', 'Layers'), **kwargs):
        # Change defaults
        kwargs.setdefault('center', [0, 0])
        kwargs.setdefault('zoom', 2)
        kwargs.setdefault('scroll_wheel_zoom', True)
        kwargs.setdefault('max_zoom', 22)
        super(Map, self).__init__(**kwargs)
        self.is_shown = False

        # Width and Height
        self.width = kwargs.get('width', None)
        self.height = kwargs.get('height', None)
        self.setDimensions(self.width, self.height)
github osm-fr / osmose-backend / modules / jupyter.py View on Github external
features = j['features']
    if limit is not None:
        features = features[0:limit]

    for f in features:
        location = (f['geometry']['coordinates'][1], f['geometry']['coordinates'][0])
        marker = Marker(location = location)
        marker.popup = HTML(str(f['properties']))
        layer_group.add_layer(marker)
        if not center:
            center = location

    if not center:
        center = (0, 0)

    m = Map(
        layers = (basemap_to_tiles(basemaps.OpenStreetMap.Mapnik), ),
        center = center,
        zoom = 8
    )

    m.add_layer(layer_group)
    return m