Update map
https://maphub.net/api/1/map/update
Update a map, including the GeoJSON.
For GeoJSON it means that the contents of the whole map is replaced with the new supplied geojson
data.
Only the included arguments will be updated. For example if only short_name
is included, nothing else will be changed.
When updating the GeoJSON of a map, images and markers are "linked", you do not need to upload them again.
Static map image is not updated automatically. If you'd like to update it, call the refresh map image endpoint manually.
A new map version is not saved.
Arguments
-
map_id (required): the id of the map. To find out a map's id, please use the list maps endpoint.
-
title (optional): The title of the map.
-
short_name (optional): The short name of the map, used in the URL.
-
description (optional): The description of the map.
-
geojson (optional): The GeoJSON for the map. This includes information related to groups, custom icons and images as well.
-
basemap (optional): The basemap used by the map.
-
visibility (optional): The visibility setting of the map. One of
public
,unlisted
,private
.
Response
- id: id of the map
- url: URL of the map
- owner: map owner's username
- short_name: short name of the map, used in the URL
- title: title of the map
- visibility: visibility mode of the map. One of
public
,unlisted
,private
,select
.
Code example
curl
curl https://maphub.net/api/1/map/update \
--header 'Authorization: Token <api_key>' \
--data-raw '{"map_id": 12345, "short_name": "test_short_name_abc", "title": "Test Title ABC", "geojson": {"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [12.34, 56.78]}, "properties": {"title": "Test point", "description": "Test description", "group": 12345}}], "groups": [{"title": "Test group", "id": 12345}]}}'
Python
import requests
url = 'https://maphub.net/api/1/map/update'
api_key = '<api_key>'
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [12.34, 56.78]},
"properties": {
"title": 'Test point',
"description": 'Test description',
"group": 12345,
},
},
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [13.34, 57.78]},
"properties": {
"title": 'Test point 2',
"description": 'Test description',
"group": 12345,
},
}
],
"groups": [{"title": 'Test group', "id": 12345}],
}
args = {
'map_id': 12345,
'short_name': 'test_short_name_abc',
'title': 'Test Title ABC',
'geojson': geojson,
}
headers = {'Authorization': 'Token ' + api_key}
r = requests.post(url, json=args, headers=headers)
print(r.json())