How to use the ipyleaflet.Polygon 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 sassoftware / python-esppy / esppy / espapi / visuals.py View on Github external
lonlat = (o["order"] == "lon_lat")

        for key,value in data.items():
            coords = value[o["coords"]]
            a = coords.split(" ")
            points = []
            i = 0
            while True:
                if lonlat:
                    points.append((a[i + 1],a[i]))
                else:
                    points.append((a[i],a[i + 1]))
                i += 2
                if i >= len(a):
                    break
            polygon = maps.Polygon(locations=points)

            borderWidth = self.getOpt("poly_border_width",1)
            polygon.weight = borderWidth

            if borderWidth > 0:
                polygon.stroke = True
                polygon.color = self.getOpt("poly_border_color","black")
            else:
                polygon.stroke = False

            polygon.fill_color = self.getOpt("poly_fill_color","white")
            polygon.fill_opacity = self.getOpt("poly_fill_opacity",.2)

            if "text" in o:
                text = value[o["text"]]
                polygon.popup = widgets.HTML(value=text)
github xoolive / traffic / traffic / plugins / leaflet.py View on Github external
The elements passed as kwargs as passed as is to the Polygon constructor.
    """
    shape = airspace.flatten()

    kwargs = {**dict(weight=3), **kwargs}
    coords: List[Any] = []
    if shape.geom_type == "Polygon":
        coords = list((lat, lon) for (lon, lat, *_) in shape.exterior.coords)
    else:
        coords = list(
            list((lat, lon) for (lon, lat, *_) in piece.exterior.coords)
            for piece in shape
        )

    return Polygon(locations=coords, **kwargs)