You are only printing one marker on the map, so it will only display one.
Each marker must be a new google.maps.Map
object. Since you are printing via PHP, you can iterate through PHP:
$latLngList = [
'40.349859, -8.583798',
'38.720430, -9.154948',
'41.159531, -8.659574',
'40.3497085,-8.5958659'
];
//iteração da lista
foreach($latLngList as $latLng)
{
echo "var latLng = new google.maps.LatLng($latLng);
";
//criação de cada marcador
echo "var marker = new google.maps.Marker({position: latLng , map: map});
";
}
This is the basics, you should iterate over each location and create a new marker by linking to the map. I have omitted the rest of the code as it will remain pretty much the same.