Custom web server for track upload and track search
Cartograph Maps can upload tracks to your own web server and search tracks on it. You add the server as a Custom server in the user account manager: main menu → User accounts → + → Custom server.
The options:
- Authentication: turn on and enter a Username and Password if your server asks for them (HTTP authentication, e.g. Basic). Use HTTPS, so that they don’t travel in plain text. The password stays on the device; cloud sync doesn’t copy it. The username and password are sent (for uploads and searches) only while Authentication is on.
- Track search with its Url: the address the app asks for tracks.
- Track upload with its Url: the address the app uploads tracks to.
- Exclude from sync: keep this server out of cloud sync.
You can set up one or both. Without any address, the account shows as “Not set up”.
Track search
Track search finds tracks in the area shown on the map. Use it in the search manager, tab Tracks, provider Custom server: tap Connect, choose your server, enter a search term if you like, and search.
The app replaces two placeholders in the Url:
- {query}: the search term you entered, URL-encoded (empty when you entered none).
- {bbox}: the visible map area as “min longitude,max latitude,max longitude,min latitude” (the top left and the bottom right corner), in decimal degrees.
Example:
https://example.com/tracks/search.php?search={query}&boundingbox={bbox}
becomes, for instance,
https://example.com/tracks/search.php?search=Schneeberg&boundingbox=15.70,47.84,15.88,47.73
The server answers with a plain GPX file. It may contain tracks, segments and waypoints; the app shows the tracks on the map and in the result list.
Track upload
To upload a track, tap it in the track manager, choose Upload and your server. Uploads can also run after every recording (Export after recording, see Track recording).
The app sends the track as a GPX file in an HTTP multipart POST to the upload Url, in the
form field “file” (file name cartograph_maps.gpx).
The server answers with JSON:
{
"result": true,
"message": "Upload success"
}
- “result”: true on success, false on failure.
- “message”: a text the app shows after the upload.
Example: a minimal PHP script that stores the uploaded file. It has no authentication and no checks of the file, so don’t run it unchanged on a public server.
<?php
// Allow only POST requests
if ($_SERVER['REQUEST_METHOD'] !== 'POST') {
http_response_code(405);
echo json_encode([
"result" => false,
"message" => "Invalid request method"
]);
exit;
}
// Check if the file field exists
if (!isset($_FILES['file']) || $_FILES['file']['error'] !== UPLOAD_ERR_OK) {
echo json_encode([
"result" => false,
"message" => "No file uploaded or upload error"
]);
exit;
}
// OPTIONAL: Choose a destination folder
$uploadDir = __DIR__ . '/uploads';
if (!is_dir($uploadDir)) {
mkdir($uploadDir, 0777, true);
}
// Save the uploaded file
$destination = $uploadDir . '/' . basename($_FILES['file']['name']);
if (move_uploaded_file($_FILES['file']['tmp_name'], $destination)) {
echo json_encode([
"result" => true,
"message" => "Upload success"
]);
} else {
echo json_encode([
"result" => false,
"message" => "Could not move uploaded file"
]);
}
?>