Add interactive Base 4 track map with Leaflet.js
- Created new track-map page with aerial image and SVG overlay - Implemented custom rotated square markers with obstacle numbers - Added admin edit mode for placing and repositioning markers - Database migration for track_obstacles table - Modal form for adding new obstacles (replaces browser alerts) - Drag-to-reposition functionality with auto-save - Color-coded markers (green/red/black/split) for difficulty levels - Clickable popups showing obstacle details - Added track-map to navigation menu and sitemap - URL rewrite rule for clean /track-map URL
This commit is contained in:
46
src/api/track/get_obstable.php
Normal file
46
src/api/track/get_obstable.php
Normal file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// /api/track/get_obstacle.php
|
||||
header('Content-Type: text/html; charset=utf-8');
|
||||
|
||||
// Read JSON POST body
|
||||
$input = json_decode(file_get_contents('php://input'), true);
|
||||
$id = $input['id'] ?? '';
|
||||
|
||||
if (!$id) {
|
||||
http_response_code(400);
|
||||
echo "<h3>Error</h3><p>Invalid obstacle id.</p>";
|
||||
exit;
|
||||
}
|
||||
|
||||
// TODO: Replace this with DB lookup (mysqli) by id.
|
||||
// For demo return stubbed content:
|
||||
$fake = [
|
||||
'obst-camp' => [
|
||||
'title' => 'Base Camp',
|
||||
'img' => '/assets/images/camp.jpg',
|
||||
'difficulty' => 'easy',
|
||||
'desc' => 'Flat campsite with shade and water point.'
|
||||
],
|
||||
'obst-water' => [
|
||||
'title' => 'Water Crossing',
|
||||
'img' => '/assets/images/water.jpg',
|
||||
'difficulty' => 'hard',
|
||||
'desc' => 'Deep crossing after heavy rain, check depth first.'
|
||||
]
|
||||
];
|
||||
|
||||
$data = $fake[$id] ?? null;
|
||||
|
||||
if (!$data) {
|
||||
http_response_code(404);
|
||||
echo "<h3>Not found</h3><p>No details for '{$id}'.</p>";
|
||||
exit;
|
||||
}
|
||||
|
||||
// render HTML snippet for Magnific
|
||||
?>
|
||||
<img src="<?= htmlspecialchars($data['img']) ?>" alt="<?= htmlspecialchars($data['title']) ?>" style="width:100%; height:220px; object-fit:cover; border-radius:6px; margin-bottom:12px;">
|
||||
<h3><?= htmlspecialchars($data['title']) ?></h3>
|
||||
<span class="difficulty-badge <?= htmlspecialchars($data['difficulty']) ?>"><?= htmlspecialchars(ucfirst($data['difficulty'])) ?></span>
|
||||
<div class="description" style="margin-top:10px;"><?= htmlspecialchars($data['desc']) ?></div>
|
||||
<?php
|
||||
Reference in New Issue
Block a user