Dispatch map actions
Requires scope: map. Applies a list of map actions to the live project, in order. Supported action types: fly_to, jump_to, fit_bounds, go_home, zoom_in, zoom_out, pan, zoom_to_layer, add_geojson_layer, add_tile_layer, add_cog_layer, remove_layer, rename_layer, set_layer_visibility, move_layer_up, move_layer_down, update_layer_style, set_basemap_style, set_basemap_category, set_country_mask, set_custom_mask, clear_layers. add_tile_layer without a layer_id is persisted by the backend (deduplicated by URL) and the created layer is returned in the response. Each action’s parameters are described in the actions schema below.
curl --request POST \
--url https://api.mapxagent.com/api/v1/sessions/{id}/map/actions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"actions": [
{
"type": "fly_to",
"center": [
123
],
"zoom": 11,
"bearing": 123,
"pitch": 42.5
}
]
}
'import requests
url = "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions"
payload = { "actions": [
{
"type": "fly_to",
"center": [123],
"zoom": 11,
"bearing": 123,
"pitch": 42.5
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [{type: 'fly_to', center: [123], zoom: 11, bearing: 123, pitch: 42.5}]
})
};
fetch('https://api.mapxagent.com/api/v1/sessions/{id}/map/actions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'actions' => [
[
'type' => 'fly_to',
'center' => [
123
],
'zoom' => 11,
'bearing' => 123,
'pitch' => 42.5
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mapxagent.com/api/v1/sessions/{id}/map/actions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mapxagent.com/api/v1/sessions/{id}/map/actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"dispatched": 123,
"layers": [
{
"layer_id": "<string>",
"url": "<string>"
}
]
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}Authorizations
Personal API key (mkx_...) created from the MapX account.
Path Parameters
Project UUID.
Body
Map actions to apply in order. Each item must have a type; see the oneOf variants for supported types and parameters.
1Fly to a map center.
- fly_to
- jump_to
- fit_bounds
- go_home
- zoom_in
- zoom_out
- pan
- zoom_to_layer
- add_geojson_layer
- add_tile_layer
- add_cog_layer
- remove_layer
- rename_layer
- set_layer_visibility
- move_layer_up
- move_layer_down
- update_layer_style
- set_basemap_style
- set_basemap_category
- set_country_mask
- set_custom_mask
- file_generated
- clear_layers
Show child attributes
Show child attributes
curl --request POST \
--url https://api.mapxagent.com/api/v1/sessions/{id}/map/actions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"actions": [
{
"type": "fly_to",
"center": [
123
],
"zoom": 11,
"bearing": 123,
"pitch": 42.5
}
]
}
'import requests
url = "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions"
payload = { "actions": [
{
"type": "fly_to",
"center": [123],
"zoom": 11,
"bearing": 123,
"pitch": 42.5
}
] }
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
actions: [{type: 'fly_to', center: [123], zoom: 11, bearing: 123, pitch: 42.5}]
})
};
fetch('https://api.mapxagent.com/api/v1/sessions/{id}/map/actions', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'actions' => [
[
'type' => 'fly_to',
'center' => [
123
],
'zoom' => 11,
'bearing' => 123,
'pitch' => 42.5
]
]
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://api.mapxagent.com/api/v1/sessions/{id}/map/actions"
payload := strings.NewReader("{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.mapxagent.com/api/v1/sessions/{id}/map/actions")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.mapxagent.com/api/v1/sessions/{id}/map/actions")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"actions\": [\n {\n \"type\": \"fly_to\",\n \"center\": [\n 123\n ],\n \"zoom\": 11,\n \"bearing\": 123,\n \"pitch\": 42.5\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"ok": true,
"dispatched": 123,
"layers": [
{
"layer_id": "<string>",
"url": "<string>"
}
]
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}{
"error": {
"code": "bad_request",
"message": "<string>",
"details": "<unknown>"
}
}
