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
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 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 |
|
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_deck_layers(layers, tooltip=None)
Add Deck.GL layers to the layer stack
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layers |
list[dict]
|
A list of dictionaries containing the Deck.GL layers to be added. |
required |
tooltip |
str | dict
|
Either a single mustache template string applied to all layers or a dictionary where keys are layer ids and values are mustache template strings. |
None
|
Source code in maplibre/map.py
add_layer(layer, before_id=None)
Add a layer to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer |
Layer | dict
|
The Layer to be added to the map. |
required |
before_id |
str
|
The ID of an existing layer to insert the new layer before,
resulting in the new layer appearing visually beneath the existing layer.
If |
None
|
Source code in maplibre/map.py
add_mapbox_draw(options=None, position=ControlPosition.TOP_LEFT, geojson=None)
Add MapboxDraw controls to the map
Note
See MapboxDraw API Reference for available options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
options |
dict | MapboxDrawOptions
|
MapboxDraw options. |
None
|
position |
str | ControlPosition
|
The position of the MapboxDraw controls. |
TOP_LEFT
|
geojson |
dict
|
A GeoJSON Feature, FeatureCollection or Geometry to be added to the draw layer. |
None
|
Source code in maplibre/map.py
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 a source to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
id |
str
|
The unique ID of the source. |
required |
source |
Source | dict
|
The source to be added to the map. |
required |
Source code in maplibre/map.py
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_deck_layers(layers, tooltip=None)
Update Deck.GL layers
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layers |
list[dict]
|
A list of dictionaries containing the Deck.GL layers to be updated. New layers will be added. Missing layers will be removed. |
required |
tooltip |
str | dict
|
Must be set to keep tooltip even if it did not change. |
None
|
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(title='My Awesome Map', **kwargs)
Render to html
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title |
str
|
The Title of the HTML document. |
'My Awesome Map'
|
**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
Source code in maplibre/ipywidget.py
maplibre.plugins
MapboxDrawControls
Bases: BaseModel
MapboxDraw controls
Source code in maplibre/plugins.py
MapboxDrawOptions
Bases: BaseModel
MapboxDraw Options