I am trying to add markers to a google map but need to bring lat/lng values in from php/mysql. The code I have below is not working, just wondering if I am going about this the right way! Thanks!
function addMarker(lat, lng){
var point = new google.maps.LatLng(lat, lng);
var marker = new google.maps.Marker({
position: point,
map: map
});
}
function initialize() {
var mapOptions = {
center: {lat: 54.872128, lng: -6.284874},
zoom: 15
};
map = new google.maps.Map(document.getElementById('map-canvas'),
mapOptions);
<?php
$query = mysql_query("select * from tester");
while($row = mysql_fetch_array($query)){
$lat = $row['lat'];
$lng = $row['lng'];
echo ("addMarker($lat, $lng);");
}
?>
}