Upload map

https://maphub.net/api/1/map/upload

Upload a file and create a new map.

For this endpoint you'll need to

  • send the arguments as a JSON encoded string in the MapHub-API-Arg header
  • send the uploaded file as binary data in the request body

Arguments

  • file_type (required): one of kml, gpx, geojson. For ".kmz" files, use kml
  • visibility (required): one of public, private
  • title: the preferred title of the map
  • description: the preferred description of the map
  • short_name: the short name of the map, visible in the URL. This is just a preference, the final URL will be returned in the response.

Response

  • map_id: the id of the map
  • map_url: the url of the map
  • title: the final title of the map

Limitations

Right now, the following limits apply to upload:

  • maximum file size 15 MB
  • maximum processing time 2 minutes

If you'd like to upload data which doesn't fit within these limits, please do so in smaller parts using the upload + append endpoints. If handling bigger amounts of data is a business requirements for your use case, please email us.

Example

curl

curl https://maphub.net/api/1/map/upload \
    --header 'Authorization: Token <api_key>' \
    --header 'MapHub-API-Arg: {"file_type": "gpx", "visibility": "public"}' \
    --data-binary @upload.gpx

Python

import json
import requests

url = 'https://maphub.net/api/1/map/upload'

api_key = '<api_key>' 

args = {
    'file_type': 'gpx',
    'visibility': 'public',
    'title': 'Upload test',
    'short_name': 'uploaded-map',
}

headers = {
    'Authorization': 'Token ' + api_key,
    'MapHub-API-Arg': json.dumps(args)
}

with open('upload.gpx', 'rb') as f:
    r = requests.post(url, headers=headers, data=f)

print(r.json())

results matching ""

    No results matching ""