I am working on incorporating multiple markers into a Google map using ajax, javascript, and php. Although there are no errors in my code, the markers are not appearing as expected. I would greatly appreciate any assistance with this issue. Please refer to the sample output of AJAX DATA below:
Array(3409)
[0 … 99]
0 : {GPS_COORDINATES: "14.901177,120.867704"}
1 : {GPS_COORDINATES: "14.620365,120.577517"}
2 : {GPS_COORDINATES: "14.869043,120.463918"}
...
Click here for a screenshot of AJAX DATA
Below is the AJAX code I have implemented:
function initMap() {
var map;
$.ajax({
url: "retailer-marker.php",
method: "POST",
data: {
search: search,
coordinator: coordinator
},
dataType: "json",
success: function(data) {
// Add your implementation logic here
},
error: function(data) {
console.log("error");
}
});
}
And here is the PHP CODE snippet:
$sql = "SELECT GPS_COORDINATES FROM ret_retailer";
$result = mysqli_query($conn, $sql);
$data = array();
foreach ($result as $row) {
$data[] = $row;
}
print json_encode($data);