first
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
<?php
|
||||
header('Content-Type: application/json');
|
||||
include __DIR__ . '/../db_config.php';
|
||||
|
||||
$sql = "SELECT id, nama, alamat, pic, latitude, longitude, radius_m, created_at FROM rumah_ibadah ORDER BY created_at DESC";
|
||||
$result = $conn->query($sql);
|
||||
$features = [];
|
||||
|
||||
if ($result && $result->num_rows > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
$lat = isset($row['latitude']) ? (float)$row['latitude'] : null;
|
||||
$lng = isset($row['longitude']) ? (float)$row['longitude'] : null;
|
||||
$props = $row;
|
||||
unset($props['latitude'], $props['longitude']);
|
||||
$features[] = [
|
||||
'type' => 'Feature',
|
||||
'geometry' => [ 'type' => 'Point', 'coordinates' => [$lng, $lat] ],
|
||||
'properties' => $props
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
echo json_encode([ 'type' => 'FeatureCollection', 'features' => $features ]);
|
||||
$conn->close();
|
||||
Reference in New Issue
Block a user