multiple marker in google map php/javascript/mysql

Hi im doing a webpage that will ask user to input date range and time range
and it will ouput tabular data and below that it will plot it on googlemap
its working fine but it only show one marker on google map
i need it to show all the data marker inshort multiple marker

this is my php query code
[php]while($row = mysqli_fetch_array($query)){
$station = $row[‘STATION’];
$pei = $row[‘PEIS’];
$pga= $row[‘PGA’];
$pgv= $row[‘PGV’];
$lat = $row[‘LAT’];
$lon = $row[‘LON’];

								//$timestamp = strtotime()
					
								echo '<tr><td>'.$station.'</td><td>'.$pei.'</td><td>'.$pga.'</td><td>'.$pgv.'</td></tr>';

														}
								
														}
														}[/php]

this is my javascript code

[code][code]

  function initMap() {

var myLatLng = {lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>};
var map = new google.maps.Map(document.getElementById(‘map’),
{
zoom: 4,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: ‘Hello World!’
});
}

</script>[/code][/code]

Hi im doing a webpage that will ask user to input date range and time range
and it will ouput tabular data and below that it will plot it on googlemap
its working fine but it only show one marker on google map
i need it to show all the data marker inshort multiple marker

this is my php query code
[php]
while($row = mysqli_fetch_array($query)){
$station = $row[‘STATION’];
$pei = $row[‘PEIS’];
$pga= $row[‘PGA’];
$pgv= $row[‘PGV’];
$lat = $row[‘LAT’];
$lon = $row[‘LON’];

								//$timestamp = strtotime()
					
								echo '<tr><td>'.$station.'</td><td>'.$pei.'</td><td>'.$pga.'</td><td>'.$pgv.'</td></tr>';

														}
								
														}
														}[/php]

and this is my javascript code

[code]

  function initMap() {

var myLatLng = {lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>};
var map = new google.maps.Map(document.getElementById(‘map’),
{
zoom: 4,
center: myLatLng
});
var marker = new google.maps.Marker({
position: myLatLng,
map: map,
title: ‘Hello World!’
});
}

</script>[/code]

No need to duplicate topics, merged.

If you want multiple markers added, you need to loop thru the values to add additional. You are only adding a single marker in the map as is…

[php] var myLatLng = {lat: <?php echo $lat; ?>, lng: <?php echo $lon; ?>};[/php]

Sponsor our Newsletter | Privacy Policy | Terms of Service