How to use the ipyleaflet.Polyline 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 xoolive / traffic / traffic / plugins / leaflet.py View on Github external
Example usage:

    >>> from ipyleaflet import Map
    >>> # Center the map near the landing airport
    >>> m = Map(center=flight.at().latlon, zoom=7)
    >>> m.add_layer(flight)  # this works as well with default options
    >>> m.add_layer(flight.leaflet(color='red'))
    >>> m
    """
    shape = flight.shape
    if shape is None:
        return None

    kwargs = {**dict(fill_opacity=0, weight=3), **kwargs}
    return Polyline(
        locations=list((lat, lon) for (lon, lat, _) in shape.coords), **kwargs
    )
github deeplook / ipyrest / ipyrest / responseviews.py View on Github external
obj = resp.content.decode('utf-8')
        try:
            trace = gpxpy.parse(obj)
        except GPXXMLSyntaxException:
            return None
        pts = [p.point for p in trace.get_points_data()]
        bbox = trace.get_bounds()
        mins = (bbox.min_latitude, bbox.min_longitude)
        maxs = (bbox.max_latitude, bbox.max_longitude)
        bbox = mins, maxs
        center = list(bbox_center(*bbox))
        z = zoom_for_bbox(*(mins + maxs))
        m = ipyleaflet.Map(center=center, zoom=z + 1)
        # FIXME: make path styling configurable
        poly = ipyleaflet.Polyline(locations=[(p.latitude, p.longitude)
            for p in pts], fill=False)
        m.add_layer(layer=poly)
        for p in pts:
            cm = ipyleaflet.CircleMarker(location=(p.latitude, p.longitude), radius=5)
            m.add_layer(layer=cm)
        self.data = m
        return m
github xoolive / traffic / traffic / plugins / leaflet.py View on Github external
shape = flightplan.shape
    if shape is None:
        return None

    coords: Iterable = list()
    if isinstance(shape, LineString):
        coords = list((lat, lon) for (lon, lat, *_) in shape.coords)
    else:
        # In case a FlightPlan could not resolve all parts
        coords = list(
            list((lat, lon) for (lon, lat, *_) in s.coords) for s in shape
        )

    kwargs = {**dict(fill_opacity=0, weight=3), **kwargs}
    return Polyline(locations=coords, **kwargs)