Upload semua tugas SIG
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// get_spbu.php
|
||||
header('Content-Type: application/json');
|
||||
$conn = new mysqli("localhost", "root", "", "db_tugas_1_sig"); // sesuaikan dengan database kamu
|
||||
|
||||
$response = [];
|
||||
$result = $conn->query("SELECT * FROM data_spbu");
|
||||
|
||||
while($row = $result->fetch_assoc()) {
|
||||
$geo = json_decode($row['geojson'], true);
|
||||
// Ekstrak koordinat Longitude dan Latitude dari objek GeoJSON Point
|
||||
$lng = $geo['geometry']['coordinates'][0];
|
||||
$lat = $geo['geometry']['coordinates'][1];
|
||||
|
||||
$response[] = [
|
||||
'id' => $row['id'],
|
||||
'nama' => $row['nama_spbu'],
|
||||
'status_24jam' => $row['status_24jam'],
|
||||
'alamat' => $row['alamat'],
|
||||
'lat' => $lat,
|
||||
'lng' => $lng
|
||||
];
|
||||
}
|
||||
|
||||
echo json_encode($response);
|
||||
$conn->close();
|
||||
?>
|
||||
Reference in New Issue
Block a user