# Map layer

Contains map layer object structure and API calls to interact with it.

## Map layer object structure:

```json
{
  "id": 123456,
  "label": "test"
}
```

* `id` - int. Map layer entity ID.
* `label` - string. Map layer name.

## API actions

API path: `/map_layer`.

### read

Reads the body of the specified layer.

#### Parameters

| name | description          | type | format |
| ---- | -------------------- | ---- | ------ |
| id   | ID of the map layer. | int  | 123456 |

#### Examples

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/map_layer/read' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "id": 123456}'
```

{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/map_layer/read?hash=a6aa75587e5c59c32d347da438505fc3&id=123456
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

Layer body with content-type: `application/vnd.google-earth.kml+xml; charset=utf-8`.

#### Errors

* 201 - Not found in the database – if there is no map layer with such ID belonging to current user.

### list

Returns metadata for all map layers for the user.

#### Parameters

Only API key `hash`.

#### Examples

{% tabs %}
{% tab title="cURL" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/map_layer/list' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b"}'
```

{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/map_layer/listd?hash=a6aa75587e5c59c32d347da438505fc3
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true,
  "list": [
    {
      "id": 123456,
      "label": "test"
    }
  ]
}
```

#### Errors

No specific errors.

### upload

Uploads new map layer.

**MUST** be a POST multipart request (multipart/form-data), with one of the parts being a KML file upload\
(with the name "file").

#### Parameters

| name             | description                                                                                                                          | type        |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------ | ----------- |
| label            | Label for a new map layer.                                                                                                           | string      |
| file             | A KML file upload containing map\_layer data.                                                                                        | File upload |
| redirect\_target | Optional. URL to redirect. If **redirect\_target** passed return redirect to `<redirect_target>?response=<urlencoded_response_json>` | string      |

#### Response

```json
{
  "success": true,
  "id": 163
}
```

* `id` - int. ID of the created layer.

#### Errors

* 233 - No data file – if file part is missing.
* 234 - Invalid data format – if file has wrong mime type.
* 242 - Validation error – if uploaded file is not valid KML.
* 268 - Over quota – if the user's quota for map layers exceeded.

### update

Updates metadata for the specified map layer.

#### Parameters

| name  | description                                                    | type        |
| ----- | -------------------------------------------------------------- | ----------- |
| layer | Map layer object described [here](#map-layer-object-structure) | JSON object |

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database – if there is no map layer with such ID belonging to current user.

### delete

Deletes specified layer.

#### Parameters

| name | description          | type | format |
| ---- | -------------------- | ---- | ------ |
| id   | ID of the map layer. | int  | 123456 |

#### Examples

{% tabs %}
{% tab title="cURL" %}
{% code overflow="wrap" %}

```sh
curl -X POST 'https://api.eu.navixy.com/v2/map_layer/delete' \
    -H 'Content-Type: application/json' \
    -d '{"hash": "22eac1c27af4be7b9d04da2ce1af111b", "id": 123456}'
```

{% endcode %}
{% endtab %}

{% tab title="HTTP GET" %}
{% code overflow="wrap" %}

```http
https://api.eu.navixy.com/v2/map_layer/delete?hash=a6aa75587e5c59c32d347da438505fc3&id=123456
```

{% endcode %}
{% endtab %}
{% endtabs %}

#### Response

```json
{
  "success": true
}
```

#### Errors

* 201 - Not found in the database – if there is no map layer with such ID belonging to current user.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://navixy.com/docs/navixy-api/user-api/backend-api/resources/tracking/map_layer.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
