map_tools module¶
MapSession
¶
Manages a leafmap session with map instance.
Source code in geoai/agents/map_tools.py
7 8 9 10 11 12 13 14 15 16 17 | |
__init__(m=None)
¶
Initialize map session.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
m
|
Optional[Map]
|
Optional existing map instance. If None, creates a default map. |
None
|
Source code in geoai/agents/map_tools.py
10 11 12 13 14 15 16 17 | |
MapTools
¶
Collection of tools for interacting with leafmap instances.
Source code in geoai/agents/map_tools.py
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 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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 | |
__init__(session=None)
¶
Initialize map tools.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
session
|
Optional[MapSession]
|
Optional MapSession instance. If None, creates a default session. |
None
|
Source code in geoai/agents/map_tools.py
23 24 25 26 27 28 29 | |
add_basemap(name)
¶
Add a basemap to the map by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the basemap to add. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message with basemap name. |
Source code in geoai/agents/map_tools.py
66 67 68 69 70 71 72 73 74 75 76 77 | |
add_cog_layer(url, name=None, attribution='TiTiler', opacity=1.0, visible=True, bands=None, nodata=0, titiler_endpoint=None)
¶
Add a Cloud Optimized GeoTIFF (COG) layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
URL to the COG file. |
required |
name
|
Optional[str]
|
Optional name for the layer. |
None
|
attribution
|
str
|
Attribution text (default: "TiTiler"). |
'TiTiler'
|
opacity
|
float
|
Layer opacity from 0.0 to 1.0 (default: 1.0). |
1.0
|
visible
|
bool
|
Whether the layer is initially visible (default: True). |
True
|
bands
|
Optional[List[int]]
|
Optional list of band indices to display. |
None
|
nodata
|
Optional[Union[int, float]]
|
No data value (default: 0). |
0
|
titiler_endpoint
|
str
|
TiTiler endpoint URL (default: "https://giswqs-titiler-endpoint.hf.space"). |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message with COG URL. |
Source code in geoai/agents/map_tools.py
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 | |
add_colorbar(width=3.0, height=0.2, vmin=0, vmax=1.0, palette=None, vis_params=None, cmap='gray', discrete=False, label=None, label_size=10, label_weight='normal', tick_size=8, bg_color='white', orientation='horizontal', dpi='figure', transparent=False, position='bottom-right', **kwargs)
¶
Add a colorbar to the map.
This function uses matplotlib to generate a colorbar, saves it as a PNG file, and adds it to the map using the Map.add_html() method. The colorbar can be customized in various ways including its size, color palette, label, and orientation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
width
|
Optional[float]
|
Width of the colorbar in inches. Defaults to 3.0. |
3.0
|
height
|
Optional[float]
|
Height of the colorbar in inches. Defaults to 0.2. |
0.2
|
vmin
|
Optional[float]
|
Minimum value of the colorbar. Defaults to 0. |
0
|
vmax
|
Optional[float]
|
Maximum value of the colorbar. Defaults to 1.0. |
1.0
|
palette
|
Optional[List[str]]
|
List of colors or a colormap name for the colorbar. Defaults to None. |
None
|
vis_params
|
Optional[Dict[str, Union[str, float, int]]]
|
Visualization parameters as a dictionary. |
None
|
cmap
|
Optional[str]
|
Matplotlib colormap name. Defaults to "gray". |
'gray'
|
discrete
|
Optional[bool]
|
Whether to create a discrete colorbar. Defaults to False. |
False
|
label
|
Optional[str]
|
Label for the colorbar. Defaults to None. |
None
|
label_size
|
Optional[int]
|
Font size for the colorbar label. Defaults to 10. |
10
|
label_weight
|
Optional[str]
|
Font weight for the colorbar label. Defaults to "normal". |
'normal'
|
tick_size
|
Optional[int]
|
Font size for the colorbar tick labels. Defaults to 8. |
8
|
bg_color
|
Optional[str]
|
Background color for the colorbar. Defaults to "white". |
'white'
|
orientation
|
Optional[str]
|
Orientation of the colorbar ("vertical" or "horizontal"). Defaults to "horizontal". |
'horizontal'
|
dpi
|
Optional[Union[str, float]]
|
Resolution in dots per inch. If 'figure', uses the figure's dpi value. Defaults to "figure". |
'figure'
|
transparent
|
Optional[bool]
|
Whether the background is transparent. Defaults to False. |
False
|
position
|
str
|
Position of the colorbar on the map. Defaults to "bottom-right". |
'bottom-right'
|
**kwargs
|
Any
|
Additional keyword arguments passed to matplotlib.pyplot.savefig(). |
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
Path to the generated colorbar image. |
Source code in geoai/agents/map_tools.py
1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 | |
add_data(data, column, cmap=None, colors=None, labels=None, scheme='Quantiles', k=5, add_legend=True, legend_title=None, legend_position='bottom-right', legend_kwds=None, classification_kwds=None, legend_args=None, layer_type=None, extrude=False, scale_factor=1.0, filter=None, paint=None, name=None, fit_bounds=True, visible=True, opacity=1.0, before_id=None, source_args={}, **kwargs)
¶
Add vector data to the map with a variety of classification schemes.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str | DataFrame | GeoDataFrame
|
The data to classify. It can be a filepath to a vector dataset, a pandas dataframe, or a geopandas geodataframe. |
required |
column
|
str
|
The column to classify. |
required |
cmap
|
str
|
The name of a colormap recognized by matplotlib. Defaults to None. |
None
|
colors
|
list
|
A list of colors to use for the classification. Defaults to None. |
None
|
labels
|
list
|
A list of labels to use for the legend. Defaults to None. |
None
|
scheme
|
str
|
Name of a choropleth classification scheme (requires mapclassify). Name of a choropleth classification scheme (requires mapclassify). A mapclassify.MapClassifier object will be used under the hood. Supported are all schemes provided by mapclassify (e.g. 'BoxPlot', 'EqualInterval', 'FisherJenks', 'FisherJenksSampled', 'HeadTailBreaks', 'JenksCaspall', 'JenksCaspallForced', 'JenksCaspallSampled', 'MaxP', 'MaximumBreaks', 'NaturalBreaks', 'Quantiles', 'Percentiles', 'StdMean', 'UserDefined'). Arguments can be passed in classification_kwds. |
'Quantiles'
|
k
|
int
|
Number of classes (ignored if scheme is None or if column is categorical). Default to 5. |
5
|
add_legend
|
bool
|
Whether to add a legend to the map. Defaults to True. |
True
|
legend_title
|
str
|
The title of the legend. Defaults to None. |
None
|
legend_position
|
str
|
The position of the legend. Can be 'top-left', 'top-right', 'bottom-left', or 'bottom-right'. Defaults to 'bottom-right'. |
'bottom-right'
|
legend_kwds
|
dict
|
Keyword arguments to pass to :func: |
None
|
classification_kwds
|
dict
|
Keyword arguments to pass to mapclassify. Defaults to None. |
None
|
legend_args
|
dict
|
Additional keyword arguments for the add_legend method. Defaults to None. |
None
|
layer_type
|
str
|
The type of layer to add. Can be 'circle', 'line', or 'fill'. Defaults to None. |
None
|
filter
|
dict
|
The filter to apply to the layer. If None, no filter is applied. |
None
|
paint
|
dict
|
The paint properties to apply to the layer. If None, no paint properties are applied. |
None
|
name
|
str
|
The name of the layer. If None, a random name is generated. |
None
|
fit_bounds
|
bool
|
Whether to adjust the viewport of the map to fit the bounds of the GeoJSON data. Defaults to True. |
True
|
visible
|
bool
|
Whether the layer is visible or not. Defaults to True. |
True
|
before_id
|
str
|
The ID of an existing layer before which the new layer should be inserted. |
None
|
source_args
|
dict
|
Additional keyword arguments that are passed to the GeoJSONSource class. |
{}
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the GeoJSON class, such as fields, which can be a list of column names to be included in the popup. |
{}
|
Source code in geoai/agents/map_tools.py
1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 | |
add_draw_control(options=None, controls=None, position='top-right', geojson=None, **kwargs)
¶
Adds a drawing control to the map.
This method enables users to add interactive drawing controls to the map, allowing for the creation, editing, and deletion of geometric shapes on the map. The options, position, and initial GeoJSON can be customized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
Optional[Dict[str, Any]]
|
Configuration options for the drawing control. Defaults to None. |
None
|
controls
|
Optional[Dict[str, Any]]
|
The drawing controls to enable. Can be one or more of the following: 'polygon', 'line_string', 'point', 'trash', 'combine_features', 'uncombine_features'. Defaults to None. |
None
|
position
|
str
|
The position of the control on the map. Defaults to "top-right". |
'top-right'
|
geojson
|
Optional[Dict[str, Any]]
|
Initial GeoJSON data to load into the drawing control. Defaults to None. |
None
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the drawing control. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
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 | |
add_html(html, bg_color='white', position='bottom-right', **kwargs)
¶
Add HTML content to the map.
This method allows for the addition of arbitrary HTML content to the map, which can be used to display custom information or controls. The background color and position of the HTML content can be customized.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
The HTML content to add. |
required |
bg_color
|
str
|
The background color of the HTML content. Defaults to "white". To make the background transparent, set this to "transparent". To make the background half transparent, set this to "rgba(255, 255, 255, 0.5)". |
'white'
|
position
|
str
|
The position of the HTML content on the map. Can be one of "top-left", "top-right", "bottom-left", "bottom-right". Defaults to "bottom-right". |
'bottom-right'
|
**kwargs
|
Union[str, int, float]
|
Additional keyword arguments for future use. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 | |
add_image(id=None, image=None, width=None, height=None, coordinates=None, position=None, icon_size=1.0, **kwargs)
¶
Add an image to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
str
|
The layer ID of the image. |
None
|
image
|
Union[str, Dict, ndarray]
|
The URL or local file path to the image, or a dictionary containing image data, or a numpy array representing the image. |
None
|
width
|
int
|
The width of the image. Defaults to None. |
None
|
height
|
int
|
The height of the image. Defaults to None. |
None
|
coordinates
|
List[float]
|
The longitude and latitude coordinates to place the image. |
None
|
position
|
str
|
The position of the image. Defaults to None. Can be one of 'top-right', 'top-left', 'bottom-right', 'bottom-left'. |
None
|
icon_size
|
float
|
The size of the icon. Defaults to 1.0. |
1.0
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 | |
add_labels(source, column, name=None, text_size=14, text_anchor='center', text_color='black', min_zoom=None, max_zoom=None, layout=None, paint=None, before_id=None, opacity=1.0, visible=True, **kwargs)
¶
Adds a label layer to the map.
This method adds a label layer to the map using the specified source and column for text values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
Union[str, Dict[str, Any]]
|
The data source for the labels. It can be a GeoJSON file path or a dictionary containing GeoJSON data. |
required |
column
|
str
|
The column name in the source data to use for the label text. |
required |
name
|
Optional[str]
|
The name of the label layer. If None, a random name is generated. Defaults to None. |
None
|
text_size
|
int
|
The size of the label text. Defaults to 14. |
14
|
text_anchor
|
str
|
The anchor position of the text. Can be "center", "left", "right", etc. Defaults to "center". |
'center'
|
text_color
|
str
|
The color of the label text. Defaults to "black". |
'black'
|
min_zoom
|
Optional[float]
|
The minimum zoom level at which the labels are visible. Defaults to None. |
None
|
max_zoom
|
Optional[float]
|
The maximum zoom level at which the labels are visible. Defaults to None. |
None
|
layout
|
Optional[Dict[str, Any]]
|
Additional layout properties for the label layer. Defaults to None. For more information, refer to https://maplibre.org/maplibre-style-spec/layers/#symbol. |
None
|
paint
|
Optional[Dict[str, Any]]
|
Additional paint properties for the label layer. Defaults to None. |
None
|
before_id
|
Optional[str]
|
The ID of an existing layer before which the new layer should be inserted. Defaults to None. |
None
|
opacity
|
float
|
The opacity of the label layer. Defaults to 1.0. |
1.0
|
visible
|
bool
|
Whether the label layer is visible by default. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments to customize the label layer. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 | |
add_layer_control(layer_ids=None, theme='default', css_text=None, position='top-left', bg_layers=False)
¶
Adds a layer control to the map.
This function creates and adds a layer switcher control to the map, allowing users to toggle the visibility of specified layers. The appearance and functionality of the layer control can be customized with parameters such as theme, CSS styling, and position on the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_ids
|
Optional[List[str]]
|
A list of layer IDs to include in the control. If None, all layers in the map will be included. Defaults to None. |
None
|
theme
|
str
|
The theme for the layer switcher control. Can be "default" or other custom themes. Defaults to "default". |
'default'
|
css_text
|
Optional[str]
|
Custom CSS text for styling the layer control. If None, a default style will be applied. Defaults to None. |
None
|
position
|
str
|
The position of the layer control on the map. Can be "top-left", "top-right", "bottom-left", or "bottom-right". Defaults to "top-left". |
'top-left'
|
bg_layers
|
bool
|
If True, background layers will be included in the control. Defaults to False. |
False
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 | |
add_legend(title='Legend', legend_dict=None, labels=None, colors=None, fontsize=15, bg_color='white', position='bottom-right', builtin_legend=None, shape_type='rectangle', **kwargs)
¶
Adds a legend to the map.
This method allows for the addition of a legend to the map. The legend can be customized with a title, labels, colors, and more. A built-in legend can also be specified.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
The title of the legend. Defaults to "Legend". |
'Legend'
|
legend_dict
|
Optional[Dict[str, str]]
|
A dictionary with legend items as keys and colors as values.
If provided, |
None
|
labels
|
Optional[List[str]]
|
A list of legend labels. Defaults to None. |
None
|
colors
|
Optional[List[str]]
|
A list of colors corresponding to the labels. Defaults to None. |
None
|
fontsize
|
int
|
The font size of the legend text. Defaults to 15. |
15
|
bg_color
|
str
|
The background color of the legend. Defaults to "white". To make the background transparent, set this to "transparent". To make the background half transparent, set this to "rgba(255, 255, 255, 0.5)". |
'white'
|
position
|
str
|
The position of the legend on the map. Can be one of "top-left", "top-right", "bottom-left", "bottom-right". Defaults to "bottom-right". |
'bottom-right'
|
builtin_legend
|
Optional[str]
|
The name of a built-in legend to use. Defaults to None. |
None
|
shape_type
|
str
|
The shape type of the legend items. Can be one of "rectangle", "circle", or "line". |
'rectangle'
|
**kwargs
|
Union[str, int, float]
|
Additional keyword arguments for future use. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 | |
add_mapillary(minzoom=6, maxzoom=14, sequence_lyr_name='sequence', image_lyr_name='image', before_id=None, sequence_paint=None, image_paint=None, image_minzoom=17, add_popup=True, access_token=None, opacity=1.0, visible=True, add_to_sidebar=False, style='photo', radius=5e-05, height=420, frame_border=0, default_message='No Mapillary image found', widget_icon='mdi-image', widget_label='Mapillary StreetView', **kwargs)
¶
Adds Mapillary layers to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
minzoom
|
int
|
Minimum zoom level for the Mapillary tiles. Defaults to 6. |
6
|
maxzoom
|
int
|
Maximum zoom level for the Mapillary tiles. Defaults to 14. |
14
|
sequence_lyr_name
|
str
|
Name of the sequence layer. Defaults to "sequence". |
'sequence'
|
image_lyr_name
|
str
|
Name of the image layer. Defaults to "image". |
'image'
|
before_id
|
str
|
The ID of an existing layer to insert the new layer before. Defaults to None. |
None
|
sequence_paint
|
dict
|
Paint properties for the sequence layer. Defaults to None. |
None
|
image_paint
|
dict
|
Paint properties for the image layer. Defaults to None. |
None
|
image_minzoom
|
int
|
Minimum zoom level for the image layer. Defaults to 17. |
17
|
add_popup
|
bool
|
Whether to add popups to the layers. Defaults to True. |
True
|
access_token
|
str
|
Access token for Mapillary API. Defaults to None. |
None
|
opacity
|
float
|
Opacity of the Mapillary layers. Defaults to 1.0. |
1.0
|
visible
|
bool
|
Whether the Mapillary layers are visible. Defaults to True. |
True
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If no access token is provided. |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 | |
add_marker(lng_lat, popup=None, options=None)
¶
Adds a marker to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lng_lat
|
List[Union[float, float]]
|
A list of two floats representing the longitude and latitude of the marker. |
required |
popup
|
Optional[str]
|
The text to display in a popup when the marker is clicked. Defaults to None. |
None
|
options
|
Optional[Dict]
|
A dictionary of options to customize the marker. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 | |
add_nlcd(years=[2023], add_legend=True, **kwargs)
¶
Adds National Land Cover Database (NLCD) data to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
years
|
list
|
A list of years to add. It can be any of 1985-2023. Defaults to [2023]. |
[2023]
|
add_legend
|
bool
|
Whether to add a legend to the map. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the add_cog_layer method. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 | |
add_nwi_basemap(name='NWI Wetlands', format='image/png', attribution='USFWS', opacity=1.0, visible=True, tile_size=256, before_id=None, overwrite=False, **kwargs)
¶
Adds a NWI Wetlands basemap to the map.
This method adds a NWI Wetlands basemap to the map. The NWI Wetlands basemap is created from the specified URL, and it is added to the map with the specified name, attribution, visibility, and tile size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name to use for the layer. Defaults to 'NWI Wetlands'. |
'NWI Wetlands'
|
format
|
str
|
The format of the tiles in the layer. |
'image/png'
|
attribution
|
str
|
The attribution to use for the layer. Defaults to ''. |
'USFWS'
|
visible
|
bool
|
Whether the layer should be visible by default. Defaults to True. |
True
|
tile_size
|
int
|
The size of the tiles in the layer. Defaults to 256. |
256
|
before_id
|
str
|
The ID of an existing layer before which the new layer should be inserted. |
None
|
overwrite
|
bool
|
Whether to overwrite an existing layer with the same name. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments that are passed to the Layer class. See https://eodagmbh.github.io/py-maplibregl/api/layer/ for more information. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
add_overture_3d_buildings(release=None, style=None, values=None, colors=None, visible=True, opacity=1.0, tooltip=True, template='simple', fit_bounds=False, **kwargs)
¶
Add 3D buildings from Overture Maps to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
release
|
Optional[str]
|
The release date of the Overture Maps data. Defaults to the latest release. For more info, see https://github.com/OvertureMaps/overture-tiles. |
None
|
style
|
Optional[Dict[str, Any]]
|
The style dictionary for the buildings. Defaults to None. |
None
|
values
|
Optional[List[int]]
|
List of height values for color interpolation. Defaults to None. |
None
|
colors
|
Optional[List[str]]
|
List of colors corresponding to the height values. Defaults to None. |
None
|
visible
|
bool
|
Whether the buildings layer is visible. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the buildings layer. Defaults to 1.0. |
1.0
|
tooltip
|
bool
|
Whether to show tooltips on the buildings. Defaults to True. |
True
|
template
|
str
|
The template for the tooltip. It can be "simple" or "all". Defaults to "simple". |
'simple'
|
fit_bounds
|
bool
|
Whether to fit the map bounds to the buildings layer. Defaults to False. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the length of values and colors lists are not the same. |
Source code in geoai/agents/map_tools.py
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 | |
add_pmtiles(url, style=None, visible=True, opacity=1.0, exclude_mask=False, tooltip=True, properties=None, template=None, attribution='PMTiles', fit_bounds=True, **kwargs)
¶
Adds a PMTiles layer to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the PMTiles file. |
required |
style
|
dict
|
The CSS style to apply to the layer. Defaults to None. See https://docs.mapbox.com/style-spec/reference/layers/ for more info. |
None
|
visible
|
bool
|
Whether the layer should be shown initially. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
exclude_mask
|
bool
|
Whether to exclude the mask layer. Defaults to False. |
False
|
tooltip
|
bool
|
Whether to show tooltips on the layer. Defaults to True. |
True
|
properties
|
dict
|
The properties to use for the tooltips. Defaults to None. |
None
|
template
|
str
|
The template to use for the tooltips. Defaults to None. |
None
|
attribution
|
str
|
The attribution to use for the layer. Defaults to 'PMTiles'. |
'PMTiles'
|
fit_bounds
|
bool
|
Whether to zoom to the layer extent. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments to pass to the PMTilesLayer constructor. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 | |
add_raster(source, indexes=None, colormap=None, vmin=None, vmax=None, nodata=None, name='Raster', before_id=None, fit_bounds=True, visible=True, opacity=1.0, array_args=None, client_args={'cors_all': True}, overwrite=True, **kwargs)
¶
Add a local raster dataset to the map.
If you are using this function in JupyterHub on a remote server
(e.g., Binder, Microsoft Planetary Computer) and if the raster
does not render properly, try installing jupyter-server-proxy using
pip install jupyter-server-proxy, then running the following code
before calling this function. For more info, see https://bit.ly/3JbmF93.
1 2 | |
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
The path to the GeoTIFF file or the URL of the Cloud Optimized GeoTIFF. |
required |
indexes
|
int
|
The band(s) to use. Band indexing starts at 1. Defaults to None. |
None
|
colormap
|
str
|
The name of the colormap from |
None
|
vmin
|
float
|
The minimum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
vmax
|
float
|
The maximum value to use when colormapping the palette when plotting a single band. Defaults to None. |
None
|
nodata
|
float
|
The value from the band to use to interpret as not valid data. Defaults to None. |
None
|
visible
|
bool
|
Whether the layer is visible. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
array_args
|
dict
|
Additional arguments to pass to
|
None
|
client_args
|
dict
|
Additional arguments to pass to localtileserver.TileClient. Defaults to { "cors_all": False }. |
{'cors_all': True}
|
overwrite
|
bool
|
Whether to overwrite an existing layer with the same name. Defaults to True. |
True
|
**kwargs
|
Any
|
Additional keyword arguments to be passed to the underlying
|
{}
|
Source code in geoai/agents/map_tools.py
481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 | |
add_text(text, fontsize=20, fontcolor='black', bold=False, padding='5px', bg_color='white', border_radius='5px', position='bottom-right', **kwargs)
¶
Adds text to the map with customizable styling.
This method allows adding a text widget to the map with various styling options such as font size, color, background color, and more. The text's appearance can be further customized using additional CSS properties passed through kwargs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
The text to add to the map. |
required |
fontsize
|
int
|
The font size of the text. Defaults to 20. |
20
|
fontcolor
|
str
|
The color of the text. Defaults to "black". |
'black'
|
bold
|
bool
|
If True, the text will be bold. Defaults to False. |
False
|
padding
|
str
|
The padding around the text. Defaults to "5px". |
'5px'
|
bg_color
|
str
|
The background color of the text widget. Defaults to "white". To make the background transparent, set this to "transparent". To make the background half transparent, set this to "rgba(255, 255, 255, 0.5)". |
'white'
|
border_radius
|
str
|
The border radius of the text widget. Defaults to "5px". |
'5px'
|
position
|
str
|
The position of the text widget on the map. Defaults to "bottom-right". |
'bottom-right'
|
**kwargs
|
Any
|
Additional CSS properties to apply to the text widget. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 | |
add_vector(data, name=None)
¶
Add a vector dataset to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
Path or URL to the vector data file. |
required |
name
|
Optional[str]
|
Optional name for the layer. |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message with layer name. |
Source code in geoai/agents/map_tools.py
79 80 81 82 83 84 85 86 87 88 89 90 91 | |
add_vector_tile(url, layer_id, layer_type='fill', source_layer=None, name=None, paint=None, layout=None, filter=None, minzoom=None, maxzoom=None, visible=True, opacity=1.0, add_popup=True, before_id=None, source_args=None, overwrite=False, **kwargs)
¶
Adds a vector tile layer to the map.
This method adds a vector tile layer to the map using a vector tile source. Vector tiles are a data format for efficiently storing and transmitting vector map data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL template for the vector tiles. Should contain {z}, {x}, and {y} placeholders for tile coordinates. |
required |
layer_id
|
str
|
The ID of the layer within the vector tile source. |
required |
layer_type
|
str
|
The type of layer to create. Can be 'fill', 'line', 'symbol', 'circle', etc. Defaults to 'fill'. |
'fill'
|
source_layer
|
str
|
The name of the source layer within the vector tiles. If None, uses layer_id. |
None
|
name
|
str
|
The name to use for the layer. If None, uses layer_id. |
None
|
paint
|
dict
|
Paint properties for the layer. If None, uses default styling based on layer_type. |
None
|
layout
|
dict
|
Layout properties for the layer. |
None
|
filter
|
dict
|
Filter expression for the layer. |
None
|
minzoom
|
int
|
Minimum zoom level for the layer. |
None
|
maxzoom
|
int
|
Maximum zoom level for the layer. |
None
|
visible
|
bool
|
Whether the layer should be visible by default. Defaults to True. |
True
|
opacity
|
float
|
The opacity of the layer. Defaults to 1.0. |
1.0
|
add_popup
|
bool
|
Whether to add a popup to the layer. Defaults to True. |
True
|
before_id
|
str
|
The ID of an existing layer before which the new layer should be inserted. |
None
|
source_args
|
dict
|
Additional keyword arguments passed to the vector tile source. |
None
|
overwrite
|
bool
|
Whether to overwrite an existing layer with the same name. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the Layer class. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Example
m = Map() m.add_vector_tile( ... url="https://api.maptiler.com/tiles/contours/tiles.json?key={api_key}", ... layer_id="contour-lines", ... layer_type="line", ... source_layer="contour", ... paint={"line-color": "#ff69b4", "line-width": 1} ... )
Source code in geoai/agents/map_tools.py
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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
add_video(urls, coordinates, layer_id='video', before_id=None)
¶
Adds a video layer to the map.
This method allows embedding a video into the map by specifying the video URLs and the geographical coordinates that the video should cover. The video will be stretched and fitted into the specified coordinates.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
urls
|
Union[str, List[str]]
|
A single video URL or a list of video URLs. These URLs must be accessible from the client's location. |
required |
coordinates
|
List[List[float]]
|
A list of four coordinates in [longitude, latitude] format, specifying the corners of the video. The coordinates order should be top-left, top-right, bottom-right, bottom-left. |
required |
layer_id
|
str
|
The ID for the video layer. Defaults to "video". |
'video'
|
before_id
|
Optional[str]
|
The ID of an existing layer to insert the new layer before. If None, the layer will be added on top. Defaults to None. |
None
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 | |
add_wms_layer(url, layers, format='image/png', name='WMS Layer', attribution='', opacity=1.0, visible=True, tile_size=256, before_id=None, source_args=None, overwrite=False, **kwargs)
¶
Adds a WMS layer to the map.
This method adds a WMS layer to the map. The WMS is created from the specified URL, and it is added to the map with the specified name, attribution, visibility, and tile size.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
url
|
str
|
The URL of the tile layer. |
required |
layers
|
str
|
The layers to include in the WMS request. |
required |
format
|
str
|
The format of the tiles in the layer. |
'image/png'
|
name
|
str
|
The name to use for the layer. Defaults to 'WMS Layer'. |
'WMS Layer'
|
attribution
|
str
|
The attribution to use for the layer. Defaults to ''. |
''
|
visible
|
bool
|
Whether the layer should be visible by default. Defaults to True. |
True
|
tile_size
|
int
|
The size of the tiles in the layer. Defaults to 256. |
256
|
before_id
|
str
|
The ID of an existing layer before which the new layer should be inserted. |
None
|
source_args
|
dict
|
Additional keyword arguments that are passed to the RasterTileSource class. |
None
|
overwrite
|
bool
|
Whether to overwrite an existing layer with the same name. Defaults to False. |
False
|
**kwargs
|
Any
|
Additional keyword arguments that are passed to the Layer class. See https://eodagmbh.github.io/py-maplibregl/api/layer/ for more information. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 | |
create_map(center_lat=20.0, center_lon=0.0, zoom=2, style='liberty', projection='globe', use_message_queue=True)
¶
Create or reset a Leafmap map with specified parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
center_lat
|
float
|
Latitude for map center (default: 20.0). |
20.0
|
center_lon
|
float
|
Longitude for map center (default: 0.0). |
0.0
|
zoom
|
int
|
Initial zoom level (default: 2). |
2
|
style
|
str
|
Map style name (default: "liberty"). |
'liberty'
|
projection
|
str
|
Map projection (default: "globe"). |
'globe'
|
use_message_queue
|
bool
|
Whether to use message queue (default: True). |
True
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message. |
Source code in geoai/agents/map_tools.py
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 | |
first_symbol_layer_id()
¶
Get the ID of the first symbol layer in the map's current style.
Source code in geoai/agents/map_tools.py
893 894 895 896 897 898 | |
fly_to(longitude, latitude, zoom=12)
¶
Fly to a specific geographic location.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
longitude
|
float
|
Target longitude coordinate. |
required |
latitude
|
float
|
Target latitude coordinate. |
required |
zoom
|
int
|
Zoom level for the target location (default: 12). |
12
|
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message with coordinates and zoom level. |
Source code in geoai/agents/map_tools.py
93 94 95 96 97 98 99 100 101 102 103 104 105 106 | |
get_layer_names()
¶
Gets layer names as a list.
Returns:
| Name | Type | Description |
|---|---|---|
list |
list
|
A list of layer names. |
Source code in geoai/agents/map_tools.py
1455 1456 1457 1458 1459 1460 1461 1462 | |
jump_to(options={}, **kwargs)
¶
Jumps the map to a specified location.
This function jumps the map to the specified location with the specified options. Additional keyword arguments can be provided to control the jump. For more information, see https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#jumpto
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
options
|
Dict[str, Any]
|
Additional options to control the jump. Defaults to {}. |
{}
|
**kwargs
|
Any
|
Additional keyword arguments to control the jump. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 | |
pan_to(lnglat, options={}, **kwargs)
¶
Pans the map to a specified location.
This function pans the map to the specified longitude and latitude coordinates. Additional options and keyword arguments can be provided to control the panning. For more information, see https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#panto
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
lnglat
|
List[float, float]
|
The longitude and latitude coordinates to pan to. |
required |
options
|
Dict[str, Any]
|
Additional options to control the panning. Defaults to {}. |
{}
|
**kwargs
|
Any
|
Additional keyword arguments to control the panning. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 | |
remove_layer(name)
¶
Remove a layer from the map by name.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the layer to remove. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Confirmation message with removed layer name. |
Source code in geoai/agents/map_tools.py
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
remove_terrain()
¶
Remove terrain visualization from the map.
Source code in geoai/agents/map_tools.py
1491 1492 1493 1494 1495 | |
rotate_to(bearing, options={}, **kwargs)
¶
Rotate the map to a specified bearing.
This function rotates the map to a specified bearing. The bearing is specified in degrees counter-clockwise from true north. If the bearing is not specified, the map will rotate to true north. Additional options and keyword arguments can be provided to control the rotation. For more information, see https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#rotateto
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bearing
|
float
|
The bearing to rotate to, in degrees counter-clockwise from true north. |
required |
options
|
Dict[str, Any]
|
Additional options to control the rotation. Defaults to {}. |
{}
|
**kwargs
|
Any
|
Additional keyword arguments to control the rotation. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 | |
save_map(output='map.html', title='My Awesome Map', width='100%', height='100%', replace_key=False, remove_port=True, preview=False, overwrite=False, **kwargs)
¶
Render the map to an HTML page.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
output
|
str
|
The output HTML file. If None, the HTML content is returned as a string. Defaults to 'map.html'. |
'map.html'
|
title
|
str
|
The title of the HTML page. Defaults to 'My Awesome Map'. |
'My Awesome Map'
|
width
|
str
|
The width of the map. Defaults to '100%'. |
'100%'
|
height
|
str
|
The height of the map. Defaults to '100%'. |
'100%'
|
replace_key
|
bool
|
Whether to replace the API key in the HTML.
If True, the API key is replaced with the public API key.
The API key is read from the environment variable |
False
|
remove_port
|
bool
|
Whether to remove the port number from the HTML. |
True
|
preview
|
bool
|
Whether to preview the HTML file in a web browser. Defaults to False. |
False
|
overwrite
|
bool
|
Whether to overwrite the output file if it already exists. |
False
|
**kwargs
|
Any
|
Additional keyword arguments that are passed to the
|
{}
|
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The HTML content of the map. |
Source code in geoai/agents/map_tools.py
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 | |
set_color(name, color)
¶
Set the color of a layer.
This method sets the color of the specified layer to the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer. |
required |
color
|
str
|
The color value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 | |
set_layout_property(name, prop, value)
¶
Set the layout property of a layer.
This method sets the layout property of the specified layer to the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer. |
required |
prop
|
str
|
The layout property to set. |
required |
value
|
Any
|
The value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
set_opacity(name, opacity)
¶
Set the opacity of a layer.
This method sets the opacity of the specified layer to the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer. |
required |
opacity
|
float
|
The opacity value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 | |
set_paint_property(name, prop, value)
¶
Set the paint property of a layer.
This method sets the opacity of the specified layer to the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer. |
required |
prop
|
str
|
The paint property to set. |
required |
value
|
Any
|
The value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 | |
set_pitch(pitch)
¶
Sets the pitch of the map.
This function sets the pitch of the map to the specified value. The pitch is the angle of the camera measured in degrees where 0 is looking straight down, and 60 is looking towards the horizon. Additional keyword arguments can be provided to control the pitch. For more information, see https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#setpitch
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pitch
|
float
|
The pitch value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
set_terrain(source='https://elevation-tiles-prod.s3.amazonaws.com/terrarium/{z}/{x}/{y}.png', exaggeration=1.0, tile_size=256, encoding='terrarium', source_id='terrain-dem')
¶
Add terrain visualization to the map.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
URL template for terrain tiles. Defaults to AWS elevation tiles. |
'https://elevation-tiles-prod.s3.amazonaws.com/terrarium/{z}/{x}/{y}.png'
|
exaggeration
|
float
|
Terrain exaggeration factor. Defaults to 1.0. |
1.0
|
tile_size
|
int
|
Tile size in pixels. Defaults to 256. |
256
|
encoding
|
str
|
Encoding for the terrain tiles. Defaults to "terrarium". |
'terrarium'
|
source_id
|
str
|
Unique identifier for the terrain source. Defaults to "terrain-dem". |
'terrain-dem'
|
Source code in geoai/agents/map_tools.py
1464 1465 1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 | |
set_visibility(name, visible)
¶
Set the visibility of a layer.
This method sets the visibility of the specified layer to the specified value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the layer. |
required |
visible
|
bool
|
The visibility value to set. |
required |
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 | |
zoom_to(zoom, options={})
¶
Zooms the map to a specified zoom level.
This function zooms the map to the specified zoom level. Additional options and keyword arguments can be provided to control the zoom. For more information, see https://maplibre.org/maplibre-gl-js/docs/API/classes/Map/#zoomto
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zoom
|
float
|
The zoom level to zoom to. |
required |
options
|
Dict[str, Any]
|
Additional options to control the zoom. Defaults to {}. |
{}
|
Returns:
| Type | Description |
|---|---|
None
|
None |
Source code in geoai/agents/map_tools.py
874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 | |