Append map
https://maphub.net/api/1/map/append
Upload a file and append to an existing map.
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.
For this endpoint you’ll need to
- send the arguments as a JSON encoded string in the
MapHub-API-Argheader - send the uploaded file as binary data in the request body
Arguments
- map_id (required): The id of the map. To find out a map’s id, please use the list maps endpoint.
- file_type (required): One of
kml,gpx,geojson,csv, orexcel. For KMZ files, usekml. For XLS, XLSX, and ODS files, useexcel. - new_group (optional): A string that names a group for the imported content. For table imports, this group becomes the import root and preserves source subgroups below it. For other formats, all imported items are placed directly in this group.
Table imports
CSV and spreadsheet appends never geocode addresses and do not consume geocoding allowance. Provide latitude and longitude columns or an inline geojson column when an item needs a location. A row without valid source geometry is preserved with no location under Unlocated Items.
Existing map items count toward the owner’s item limit. The append imports rows only up to the remaining capacity. It reuses destination groups with matching complete paths, including existing Unlocated Items groups, instead of creating duplicate groups.
Without new_group, source groups are appended at the map root. With new_group, that group is the root for all source groups and generated Unlocated Items groups.
See XLSX / CSV import for supported columns, geometry precedence, and group syntax.
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.
Limitations
Following limits apply to uploads:
- maximum file size 15 MB
- maximum processing time 2 minutes
On a MapHub Enterprise server, there are no limits. If you are interested in MapHub Enterprise, contact us.
Code example
curl with file
curl https://maphub.net/api/1/map/append \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"map_id": 12345, "file_type": "kml"}' \
--data-binary @test.kml
curl with geojson data
curl https://maphub.net/api/1/map/append \
--header 'Authorization: Token <api_key>' \
--header 'MapHub-API-Arg: {"map_id": 12345, "file_type": "geojson"}' \
--data-raw '{"type": "FeatureCollection", "features": [{"type": "Feature", "geometry": {"type": "Point", "coordinates": [23.45, 34.56]}, "properties": {"title": "Test point", "description": "Test description", "group": 12345}}], "groups": [{"title": "Test group", "id": 12345}]}'
Python with file
import json
import requests
url = 'https://maphub.net/api/1/map/append'
api_key = '<api_key>'
args = {
'map_id': 12345,
'file_type': 'kml',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
with open('test.kml', 'rb') as f:
r = requests.post(url, headers=headers, data=f)
print(r.json())
Python with geojson data
import json
import requests
url = 'https://maphub.net/api/1/map/append'
api_key = '<api_key>'
args = {
'map_id': 12345,
'file_type': 'geojson',
}
headers = {
'Authorization': 'Token ' + api_key,
'MapHub-API-Arg': json.dumps(args),
}
geojson = {
"type": "FeatureCollection",
"features": [
{
"type": "Feature",
"geometry": {"type": "Point", "coordinates": [12.34, 56.78]},
"properties": {
"title": 'Test point',
"description": 'Test description',
"group": 2345,
},
}
],
"groups": [{"title": 'Test group 234', "id": 2345}],
}
r = requests.post(url, headers=headers, data=json.dumps(geojson))
print(r.json())