Map
openlayers.Map
Bases: object
Initialize a new Map
instance
Parameters:
Name | Type | Description | Default |
---|---|---|---|
view
|
View
|
The initial view state of the map |
View()
|
layers
|
list[LayerT | LayerLike | dict]
|
Layers initially added to the map |
None
|
controls
|
list[ControlT | dict]
|
Controls initially added to the map |
None
|
Source code in openlayers/map.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 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 |
|
add_click_interaction()
add_control(control)
Add a control to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control
|
ControlT | dict
|
The control to be added |
required |
Source code in openlayers/map.py
add_default_tooltip()
Add a default tooltip to the map
It renders all feature properties and is activated for all layers of the map.
add_drag_and_drop_interaction(formats=[GeoJSON(), TopoJSON(), GPX(), KML()], style=None)
Add a drag and drop interaction to the map
Source code in openlayers/map.py
add_layer(layer)
Add a layer to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer
|
LayerT | LayerLike | dict
|
The layer to be added |
required |
Source code in openlayers/map.py
add_modify_interaction(layer_id)
Add a modify interaction to the map
Modify features of a vector layer.
Note
Layers of type WebGLVectorLayer
are not supported.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
str
|
The ID of the layer you want to modify |
required |
Source code in openlayers/map.py
add_select_interaction()
Add Select-Features
interaction to the map
Note
Currently, highlighting selected features is not supported
for layers of type WebGLVectorLayer
.
add_tooltip(template=None)
Add a tooltip to the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
template
|
str
|
A mustache template string.
If |
None
|
remove_control(control_id)
Remove a control from the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
control_id
|
str
|
The ID of the control to be removed |
required |
remove_layer(layer_id)
Remove a layer from the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
str
|
The ID of the layer to be removed |
required |
save(path=None, preview=True, **kwargs)
Save map as an HTML document
Parameters:
Name | Type | Description | Default |
---|---|---|---|
path
|
Path | str
|
The Path to the output file. If |
None
|
preview
|
bool
|
Whether the file should be opened in your default browser after saving |
True
|
Source code in openlayers/map.py
set_center(lon=0, lat=0)
Set the center of the view
Parameters:
Name | Type | Description | Default |
---|---|---|---|
lon
|
float
|
The center's longitude |
0
|
lat
|
float
|
The center's latitude |
0
|
set_opacity(layer_id, opacity=1)
Set the opacity of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
str
|
The ID of the layer |
required |
opacity
|
float
|
The opacity of the layer. A value between 0 and 1 |
1
|
Source code in openlayers/map.py
set_source(layer_id, source)
Set the source of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
{str}
|
The ID of the layer |
required |
source
|
SourceT | dict
|
The source of the layer |
required |
Source code in openlayers/map.py
set_style(layer_id, style)
Set the style of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
str
|
The ID of the layer |
required |
style
|
FlatStyle | dict
|
The style of the layer |
required |
Source code in openlayers/map.py
set_view(view)
Set the view state of the map
Parameters:
Name | Type | Description | Default |
---|---|---|---|
view
|
View
|
The view state of the map |
required |
set_visibility(layer_id, visible=False)
Set the visibility of a layer
Parameters:
Name | Type | Description | Default |
---|---|---|---|
layer_id
|
str
|
The ID of the layer |
required |
visible
|
bool
|
Whether the layer is visible or not |
False
|
Source code in openlayers/map.py
set_zoom(zoom_level)
Set the zoom level of the view
Parameters:
Name | Type | Description | Default |
---|---|---|---|
zoom_level
|
float | int
|
The zoom level |
required |
openlayers.view.View
Bases: OLBaseModel
A View object represents a simple 2D view of the map
Note
See module-ol_View-View.html for details.
Attributes:
Name | Type | Description |
---|---|---|
center |
tuple[float, float]
|
The center for the view as (lon, lat) pair |
zoom |
float | int
|
The Zoom level used to calculate the resolution for the view |
projection |
str
|
The projection |
rotation |
float | int
|
The rotation for the view in radians (positive rotation clockwise, 0 means north). |
extent |
tuple[float, float, float, float] | list[float, float, float, float]
|
The extent that constrains the view, in other words, nothing outside of this extent can be visible on the map |
min_zoom |
float | int
|
The minimum zoom level used to determine the resolution constraint |
max_zoom |
float | int
|
The maximum zoom level used to determine the resolution constraint |
Source code in openlayers/models/view.py
openlayers.MapWidget
Bases: Map
, AnyWidget
Initialize a new MapWidget
instance
Note
See Map for details.