Step 5: Update the map

Time to call the Update map endpoint with the generated GeoJSON from the previous step.

def update_map(geojson):
    with open(MAP_DATA_JSON) as f:
        map_data = json.load(f)

    url = ''

    args = {
        'map_id': map_data['id'],
        'geojson': geojson,
        'basemap': 'maphub-light',
        'description': (
            'Sample map for MapHub API tutorial:\n'
            '[Create a map from a table CSV file](\n\n'
            'Texts and images are from'
        'visibility': 'public',

    headers = {'Authorization': 'Token ' + API_KEY}

    res =, json=args, headers=headers)
    data = res.json()

    if 'id' not in data:

    print('Map updated')
    print(json.dumps(map_data, indent=2, ensure_ascii=False))

Full script file