MCPcopy Create free account
hub / github.com/python-visualization/folium / PolyLineOffset

Class PolyLineOffset

folium/plugins/polyline_offset.py:5–55  ·  view source on GitHub ↗

Add offset capabilities to the PolyLine class. This plugin adds to folium Polylines the ability to be drawn with a relative pixel offset, without modifying their actual coordinates. The offset value can be either negative or positive, for left- or right-side offset, and remains

Source from the content-addressed store, hash-verified

3
4
5class PolyLineOffset(JSCSSMixin, PolyLine):
6 """
7 Add offset capabilities to the PolyLine class.
8
9 This plugin adds to folium Polylines the ability to be drawn with a
10 relative pixel offset, without modifying their actual coordinates. The offset
11 value can be either negative or positive, for left- or right-side offset,
12 and remains constant across zoom levels.
13
14 See :func:`folium.vector_layers.path_options` for the `Path` options.
15
16 Parameters
17 ----------
18 locations: list of points (latitude, longitude)
19 Latitude and Longitude of line (Northing, Easting)
20 popup: str or folium.Popup, default None
21 Input text or visualization for object displayed when clicking.
22 tooltip: str or folium.Tooltip, optional
23 Display a text when hovering over the object.
24 offset: int, default 0
25 Relative pixel offset to draw a line parallel to an existent one,
26 at a fixed distance.
27 **kwargs:
28 Polyline options. See their Github page for the
29 available parameters.
30
31 See https://github.com/bbecquet/Leaflet.PolylineOffset
32
33 Examples
34 --------
35 >>> plugins.PolyLineOffset(
36 ... [[58, -28], [53, -23]], color="#f00", opacity=1, offset=-5
37 ... ).add_to(m)
38 >>> plugins.PolyLineOffset(
39 ... [[58, -28], [53, -23]], color="#080", opacity=1, offset=10
40 ... ).add_to(m)
41
42 """
43
44 default_js = [
45 (
46 "polylineoffset",
47 "https://cdn.jsdelivr.net/npm/leaflet-polylineoffset@1.1.1/leaflet.polylineoffset.min.js",
48 )
49 ]
50
51 def __init__(self, locations, popup=None, tooltip=None, offset=0, **kwargs):
52 super().__init__(locations=locations, popup=popup, tooltip=tooltip, **kwargs)
53 self._name = "PolyLineOffset"
54 # Add PolyLineOffset offset.
55 self.options.update({"offset": offset})

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…