Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 23 additions & 1 deletion felt_python/maps.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ def update_map(
title: str | None = None,
description: str | None = None,
public_access: str | None = None,
basemap: str | None = None,
table_settings: dict | None = None,
viewer_permissions: dict | None = None,
api_token: str | None = None,
):
"""Update a map's details
Expand All @@ -126,18 +129,37 @@ def update_map(
public_access: Optional new public access setting
Options are "private", "view_only", "view_and_comment",
or "view_comment_and_edit"
basemap: The basemap to use for the map. Defaults to "default".
Valid values are "default", "light", "dark", "satellite",
a valid raster tile URL with {x}, {y}, and {z} parameters,
or a hex color string like #ff0000.
table_settings: Optional data table settings
Dict with keys:
- "default_table_layer_id": str | None - The layer ID to open by default in table view
- "viewers_can_open_table": bool - Whether viewers can open the data table
viewer_permissions: Optional viewer permission settings
Dict with keys:
- "can_duplicate_map": bool - Whether viewers can duplicate the map and data
- "can_export_data": bool - Whether viewers can export map data
- "can_see_map_presence": bool - Whether viewers can see who else is viewing the map
api_token: Optional API token

Returns:
The updated map
"""
json_args = {}
json_args: dict = {}
if title is not None:
json_args["title"] = title
if description is not None:
json_args["description"] = description
if public_access is not None:
json_args["public_access"] = public_access
if basemap is not None:
json_args["basemap"] = basemap
if table_settings is not None:
json_args["table_settings"] = table_settings
if viewer_permissions is not None:
json_args["viewer_permissions"] = viewer_permissions

response = make_request(
url=MAP_UPDATE.format(map_id=map_id),
Expand Down
35 changes: 34 additions & 1 deletion notebooks/maps.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,43 @@
" map_id=map_id,\n",
" title=\"A felt-python map with an update\",\n",
" description=\"This map was updated through the API\",\n",
" public_access=\"view_only\"\n",
" public_access=\"view_only\",\n",
" basemap=\"dark\" # You can also update the basemap\n",
")"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Advanced map updates\n",
"\n",
"You can also update table settings and viewer permissions."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": [
"# Update map with table settings and viewer permissions\n",
"resp = update_map(\n",
" map_id=map_id,\n",
" title=\"Map with advanced settings\",\n",
" table_settings={\n",
" \"viewers_can_open_table\": True,\n",
" # \"default_table_layer_id\": \"layer_id_here\" # Optional: set default table layer\n",
" },\n",
" viewer_permissions={\n",
" \"can_duplicate_map\": True,\n",
" \"can_export_data\": False,\n",
" \"can_see_map_presence\": True\n",
" }\n",
")\n",
"print(\"Map updated with advanced settings\")"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
23 changes: 23 additions & 0 deletions tests/maps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,23 @@ def test_map_workflow(self):
updated_name = f"Test Map Updated ({self.timestamp})"
print(f"Updating map to: {updated_name}...")

# Test table_settings and viewer_permissions
table_settings = {"viewers_can_open_table": True}

viewer_permissions = {
"can_duplicate_map": True,
"can_export_data": False,
"can_see_map_presence": True,
}

updated_map = update_map(
map_id=map_id,
title=updated_name,
description=f"This map was updated through the API test at {self.timestamp}",
public_access="view_only",
basemap="dark",
table_settings=table_settings,
viewer_permissions=viewer_permissions,
)

self.assertIsNotNone(updated_map)
Expand All @@ -83,6 +95,17 @@ def test_map_workflow(self):

self.assertEqual(updated_details["title"], updated_name)
self.assertEqual(updated_details["public_access"], "view_only")
self.assertEqual(updated_details["basemap"], "dark")

# Verify table_settings and viewer_permissions were applied
if "table_settings" in updated_details:
self.assertTrue(updated_details["table_settings"]["viewers_can_open_table"])

if "viewer_permissions" in updated_details:
perms = updated_details["viewer_permissions"]
self.assertTrue(perms["can_duplicate_map"])
self.assertFalse(perms["can_export_data"])
self.assertTrue(perms["can_see_map_presence"])

# Step 4: Export comments
# Note: There will be no comments on a newly created map
Expand Down
Loading