I'm trying to use a PHP Array to get long and lat values from a database, and put these onto a map using gmaps.js.
So far, I have created the array in PHP, and echoed this onto my page to confirm the correct values are being displayed.
$data = array();
$data['latitude'] = array($lat);
$data['longitude'] = array($lng);
echo json_encode($data);
So $data is the array, with the values I want inside.
I then want to use jQuery to get the data from json encode, put these into the map marker locations and display the markers like so:
$.ajax({
type: "POST",
url: "phppage.php",
dataType: "JSON",
success: function(data) {
$.each(data, function(key, value) {
poi_marker = {
marker: {
lat: data.latitude,
lng: data.longitude,
}
}
}
poi_markers.push(poi_marker);
});
map.addMarkers(poi_markers);
}
});
I get no errors in my console (using firefox and firebug), the map displays but no markers are shown.