EasyAR provides two methods to handle spatial map data that is no longer needed: permanent deletion and temporary deactivation. To ensure production environment stability, please carefully read the following instructions.
In most business scenarios, if you are unsure whether a map will be used again in the future, we recommend using deactivation instead of deletion.
Automated cleanup of sparse spatial maps can be achieved through REST API.
Please replace the placeholder with actual parameters and run the curl script
- Your-Cloud-URL → Actual API URLs
- Your-Token → Actual API Key Authorization Token
- Your-SpatialMap-AppId → Your appId
- Your-todo-MapId → MapId to be deleted
curl -X DELETE "https://armap-api-<cn1|na1>.easyar.com/map/<Your-todo-MapId>?appId=<Your-SpatialMap-AppId>" \
-H "Content-Type: application/json" \
-H "Authorization: <Your-Token>"
Download Java sample code
Import the project via Maven
Step 1. Open the code sample RemoveMap.java
Step 2. Modify the global variables and replace the authentication parameters in your preparation list
- SpatialMap AppId
- API Key / API Secret
- Cloud URL
RemoveMap.java
import okhttp3.*;
import org.json.JSONObject;
import java.io.IOException;
import java.util.Set;
public class RemoveMap {
private static final String CLOUD_URL = "https://armap-api-<cn1|na1>.easyar.com";
private static final String SPATIALMAP_APPID= "--here is your SpatialMap AppId--";
private static final String API_KEY = "--here is your API Key--";
private static final String API_SECRET = "--here is your API Secret--";
private static final String MAPID = "my_mapId";
public String remove(Auth auth, String mapId) throws IOException {
okhttp3.Request request = new okhttp3.Request.Builder()
.url(auth.getCloudURL()+"/map/"+mapId+"?"+ Auth.toParam(
Auth.signParam(new JSONObject(), auth.getAppId(), auth.getApiKey(), auth.getApiSecret())
))
.delete()
.build();
return new OkHttpClient.Builder().build().newCall(request).execute().body().string();
}
public static void main(String[] args) throws IOException{
Auth accessInfo = new Auth(SPATIALMAP_APPID, API_KEY, API_SECRET, CLOUD_URL);
System.out.println(new RemoveMap().remove(accessInfo, MAPID));
}
}
Step 3. Run Main
Step 1. Copy the sample code to removemap.php
- Modify the authentication parameters to your actual resources: Token, appId and Cloud URL
- MapId of the map to be deleted
<?php
class MapDeleteService {
private $baseURL;
private $token;
private $appId;
public function __construct($baseURL, $token, $appId) {
$this->baseURL = $baseURL;
$this->token = $token;
$this->appId = $appId;
}
public function deleteMap($mapId) {
// Build query parameters
$queryParams = [
'appId' => $this->appId
];
$queryString = http_build_query($queryParams);
$url = $this->baseURL . '/map/' . urlencode($mapId) . '?' . $queryString;
$ch = curl_init();
curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_CUSTOMREQUEST => 'DELETE',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'Authorization: ' . $this->token,
'Content-Type: application/json'
],
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_TIMEOUT => 30
]);
echo "=== API Request ===" . PHP_EOL;
echo "URL: " . $url . PHP_EOL;
echo "Method: DELETE" . PHP_EOL;
echo "Headers: Authorization: " . $this->token . PHP_EOL;
echo "Query Params: " . json_encode($queryParams, JSON_PRETTY_PRINT) . PHP_EOL;
$response = curl_exec($ch);
$httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
$error = curl_error($ch);
curl_close($ch);
echo "=== API Response ===" . PHP_EOL;
echo "Status Code: " . $httpCode . PHP_EOL;
echo "Timestamp: " . date('c') . PHP_EOL;
if ($error) {
echo "cURL Error: " . $error . PHP_EOL;
return null;
}
$responseData = json_decode($response, true);
echo "Response Data: " . json_encode($responseData, JSON_PRETTY_PRINT) . PHP_EOL;
return $responseData;
}
}
$mapId = 'your_map_id_here';
$config = [
'baseURL' => 'https://armap-api-cn1.easyar.com',
'token' => 'your_token_here',
'appId' => 'your_app_id_here'
];
$mapDeleteService = new MapDeleteService($config['baseURL'], $config['token'], $config['appId']);
$result = $mapDeleteService->deleteMap($mapId);
if ($result) {
echo PHP_EOL . "=== Delete request successful ===" . PHP_EOL;
if (isset($result['statusCode']) && $result['statusCode'] == 200) {
echo "Result: " . json_encode($result['result'], JSON_PRETTY_PRINT) . PHP_EOL;
}
} else {
echo PHP_EOL . "=== Failed ===" . PHP_EOL;
}
?>
Step 2. Run
php removemap.php
Create the relevant code file main.go, modify the global variables, and then run
go run main.go
main.go:
package main
import (
"crypto/sha256"
"fmt"
"io"
"net/http"
"sort"
"strconv"
"time"
)
var (
ApiKey = "YOUR_API_KEY"
ApiSecret = "YOUR_API_SECRET"
AppId = "YOUR_APP_ID"
Host = "https://armap-api-<cn1|na1>.easyar.com"
MapId = "YOUR_MAP_ID"
)
func main() {
ts := strconv.FormatInt(time.Now().UnixNano()/1e6, 10)
params := map[string]string{
"apiKey": ApiKey,
"appId": AppId,
"timestamp": ts,
}
keys := []string{"apiKey", "appId", "timestamp"}
sort.Strings(keys)
builder := ""
for _, k := range keys { builder += k + params[k] }
builder += ApiSecret
signature := fmt.Sprintf("%x", sha256.Sum256([]byte(builder)))
url := fmt.Sprintf("%s/map/%s?apiKey=%s&appId=%s×tamp=%s&signature=%s",
Host, MapId, ApiKey, AppId, ts, signature)
req, _ := http.NewRequest("DELETE", url, nil)
resp, _ := http.DefaultClient.Do(req)
defer resp.Body.Close()
body, _ := io.ReadAll(resp.Body)
fmt.Printf("Response: %s\n", string(body))
}
Add reqwest, tokio, sha2, hex dependencies in Cargo.toml.
Execute cargo run.
use sha2::{Sha256, Digest};
use std::collections::BTreeMap;
use std::time::{SystemTime, UNIX_EPOCH};
const API_KEY: &str = "YOUR_API_KEY";
const API_SECRET: &str = "YOUR_API_SECRET";
const APP_ID: &str = "YOUR_APP_ID";
const HOST: &str = "https://armap-api-<cn1|na1>.easyar.com";
const MAP_ID: &str = "YOUR_MAP_ID";
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let ts = SystemTime::now().duration_since(UNIX_EPOCH)?.as_millis().to_string();
// 1. Signature components
let mut params = BTreeMap::new();
params.insert("apiKey", API_KEY);
params.insert("appId", APP_ID);
params.insert("timestamp", &ts);
// 2. Concatenate keys and values, then append secret
let mut sign_str = String::new();
for (k, v) in ¶ms {
sign_str.push_str(k);
sign_str.push_str(v);
}
sign_str.push_str(API_SECRET);
let mut hasher = Sha256::new();
hasher.update(sign_str.as_bytes());
let signature = hex::encode(hasher.finalize());
// 3. Construct URL and send DELETE
let url = format!("{}/map/{}?apiKey={}&appId={}×tamp={}&signature={}",
HOST, MAP_ID, API_KEY, APP_ID, ts, signature);
let res = reqwest::Client::new().delete(url).send().await?;
println!("Response: {}", res.text().await?);
Ok(())
}
Create .NET console project.
dotnet new console
dotnet run
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Net.Http;
class Program {
static string API_KEY = "YOUR_API_KEY";
static string API_SECRET = "YOUR_API_SECRET";
static string APP_ID = "YOUR_APP_ID";
static string HOST = "https://armap-api-<cn1|na1>.easyar.com";
static string MAP_ID = "YOUR_MAP_ID";
static async System.Threading.Tasks.Task Main() {
string timestamp = DateTimeOffset.Now.ToUnixTimeMilliseconds().ToString();
// 1. Sort parameters
var dict = new SortedDictionary<string, string> {
{ "apiKey", API_KEY },
{ "appId", APP_ID },
{ "timestamp", timestamp }
};
// 2. Concatenate and append secret
StringBuilder sb = new StringBuilder();
foreach (var kv in dict) sb.Append(kv.Key).Append(kv.Value);
sb.Append(API_SECRET);
string signature = Sha256(sb.ToString());
// 3. Execute DELETE request
using var client = new HttpClient();
string query = string.Join("&", dict.Select(x => $"{x.Key}={x.Value}")) + $"&signature={signature}";
string url = $"{HOST}/map/{MAP_ID}?{query}";
var response = await client.DeleteAsync(url);
Console.WriteLine($"Result: {await response.Content.ReadAsStringAsync()}");
}
static string Sha256(string str) {
byte[] bytes = SHA256.HashData(Encoding.UTF8.GetBytes(str));
return BitConverter.ToString(bytes).Replace("-", "").ToLower();
}
}
- Runtime environment
- Unity 2020 LTS or higher
- Scripting Backend: Mono or IL2CPP
- API Compatibility Level: .NET Standard 2.1 (recommended)
Step 1: Prepare image files
- Create directories in the Unity project:
Assets/
└── Scripts/
└── DeleteMap.cs
- below according to the Assets directory name
- Copy the sample code DeleteMap.cs
using System.Collections;
using UnityEngine;
using UnityEngine.Networking;
public class DeleteMap : MonoBehaviour
{
[Header("Config")]
public string mapId = "Your mapId";
public string apiBaseUrl = "https://armap-api-<cn1|na1>.easyar.com";
public string authorizationToken = "YOUR API KEY AUTH TOKEN";
public string spatialMapAppId = "Your Spatial Map appId";
private void Start()
{
StartCoroutine(DeleteAMap());
}
private IEnumerator DeleteAMap()
{
string url =
$"{apiBaseUrl}/map/{mapId}?appId={spatialMapAppId}";
UnityWebRequest request = UnityWebRequest.Delete(url);
request.downloadHandler = new DownloadHandlerBuffer();
request.SetRequestHeader("Content-Type", "application/json");
request.SetRequestHeader("Authorization", authorizationToken);
yield return request.SendWebRequest();
if (request.result == UnityWebRequest.Result.Success)
{
Debug.Log("Delete map success:");
Debug.Log(request.downloadHandler.text);
}
else
{
Debug.LogError("Delete map failed:");
Debug.LogError(request.error);
Debug.LogError(request.downloadHandler.text);
}
}
}
- In Unity Editor:
- Create an empty GameObject
- Name it
DeleteMap
- Drag the
DeleteMap script onto this object
Step 3: Configure parameters (Inspector)
Step 4: Run
- Click Play
- Check the result in the Console:
- Success: Returns JSON (including result)
- Failure: HTTP / Error message