Map
maplibre.Map
Bases: object
Map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
map_options |
MapOptions
|
Map options. |
MapOptions()
|
**kwargs |
Keyword arguments that are appended to the |
{}
|
Examples:
>>> map_options = MapOptions(center=(9.5, 51.31667), zoom=8)
>>> map = Map(map_options)
>>> dict(map)
{'mapOptions': {'center': (9.5, 51.31667), 'style': 'https://basemaps.cartocdn.com/gl/dark-matter-gl-style/style.json', 'zoom': 8}, 'calls': []}
Source code in maplibre/map.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
|
add_call(method_name, *args)
Add a method call that is executed on the map instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
method_name |
str
|
The name of the map method to be executed. |
required |
*args |
any
|
The arguments to be passed to the map method. |
()
|
Source code in maplibre/map.py
add_control(control, position=ControlPosition.TOP_RIGHT)
Add a control to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control |
Control
|
The control to be added to the map. |
required |
position |
str | ControlPosition
|
The position of the control. |
TOP_RIGHT
|
Source code in maplibre/map.py
add_layer(layer)
Add a layer to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
Layer | dict
|
The Layer to be added to the map. |
required |
add_marker(marker)
Add a marker to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
marker |
Marker
|
The marker to be added to the map. |
required |
add_popup(layer_id, prop=None, template=None)
Add a popup to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The layer to which the popup is added. |
required |
prop |
str
|
The property of the source to be displayed. If |
None
|
template |
str
|
A mustache template. If supplied, |
None
|
Source code in maplibre/map.py
add_source(id, source)
add_tooltip(layer_id, prop=None, template=None)
Add a tooltip to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The layer to which the tooltip is added. |
required |
prop |
str
|
The property of the source to be displayed. If |
None
|
template |
str
|
A mustache template. If supplied, |
None
|
Examples:
Source code in maplibre/map.py
set_data(source_id, data)
Update the data of a GeoJSON source
Parameters:
Name | Type | Description | Default |
---|---|---|---|
source_id |
str
|
The name of the source to be updated. |
required |
data |
dict
|
The data of the source. |
required |
Source code in maplibre/map.py
set_filter(layer_id, filter_)
Update the filter of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The name of the layer to be updated. |
required |
filter_ |
list
|
The filter expression that is applied to the source of the layer. |
required |
Source code in maplibre/map.py
set_layout_property(layer_id, prop, value)
Update a layout property of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The name of the layer to be updated. |
required |
prop |
str
|
The name of the layout property to be updated. |
required |
value |
any
|
The new value of the layout property. |
required |
Source code in maplibre/map.py
set_paint_property(layer_id, prop, value)
Update the paint property of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The name of the layer to be updated. |
required |
prop |
str
|
The name of the paint property to be updated. |
required |
value |
any
|
The new value of the paint property. |
required |
Source code in maplibre/map.py
set_visibility(layer_id, visible=True)
Update the visibility of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id |
str
|
The name of the layer to be updated. |
required |
visible |
bool
|
Whether the layer is visible or not. |
True
|
Source code in maplibre/map.py
to_html(**kwargs)
Render to html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any
|
Additional keyword arguments that are passed to the template.
Currently, |
{}
|
Examples:
>>> map = Map()
>>> with open("/tmp/map.html", "w") as f:
... f.write(map.to_html(style="height: 800px;")
Source code in maplibre/map.py
maplibre.MapOptions
Bases: BaseModel
Map options
Note
See MapOptions for more details.
Source code in maplibre/map.py
maplibre.MapContext
Bases: Map
MapContext
Use this class to update a Map
instance in a Shiny app.
Must be used inside an async function.
See maplibre.Map
for available methods.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
string
|
The id of the map to be updated. |
required |
session |
Session
|
A Shiny session.
If |
None
|
Source code in maplibre/mapcontext.py
maplibre.ipywidget.MapWidget
Bases: AnyWidget
, Map
MapWidget
Use this class to display and update maps in Jupyter Notebooks.
See maplibre.Map
for available methods.
Examples:
>>> from maplibre import MapOptions
>>> from maplibre.ipywidget import MapWidget as Map
>>> m = Map(MapOptions(center=(-123.13, 49.254), zoom=11, pitch=45))
>>> m