How to use the ipyleaflet.LayerGroup 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]
                self.state.x_slice = index#event['data']['index']
                self.reset_slice()
github sassoftware / python-esppy / esppy / espapi / visuals.py View on Github external
def addCircles(self,datasource,**kwargs):
        options = tools.Options(**kwargs)
        o = {}
        o["lat"] = options.getOpt("lat")
        o["lon"] = options.getOpt("lon")
        o["datasource"] = datasource
        o["layers"] = maps.LayerGroup()
        if options.hasOpt("radius"):
            value = options.getOpt("radius")
            try:
                num = int(value)
                o["radius"] = num
            except:
                o["radius_field"] = value
        if options.hasOpt("text"):
            o["text"] = options.getOpt("text")
        self._circles.append(o)
        self.loadCircles(o)
        datasource.addDelegate(self)
github sassoftware / python-esppy / esppy / espapi / visuals.py View on Github external
def addPolygons(self,datasource,**kwargs):
        options = tools.Options(**kwargs)
        o = {}
        o["coords"] = options.getOpt("coords")
        o["datasource"] = datasource
        o["layers"] = maps.LayerGroup()
        if options.hasOpt("text"):
            o["text"] = options.getOpt("text")
        o["order"] = options.getOpt("order","lat_lon")
        self._polygons.append(o)
        self.loadPolygons(o)
        datasource.addDelegate(self)
github osm-fr / osmose-backend / modules / jupyter.py View on Github external
def print_geojson(geojson, limit = 100):
    center = None
    j = json.load(StringIO(geojson))
    layer_group = LayerGroup()

    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)