I am trying to display the address which is called from my sql database, I can't display the address I keep getting this error "Geocode was not successful for the following reason Zero_Results"
I tried to add the full address in one variable $address rather than using three variable $address , $county , $county but still not working and I cannot figure it out.
I would like to display the address as marker as you can see in the image.
Whenever I added new address into my db I would get new marker added into the map.
Any help,
Thanks in advance.
Here is the code I am working with :
$result = mysqli_query($con,"SELECT * FROM `test`") or die ("Error:
".mysqli_error($con));
while ($row = mysqli_fetch_array($result))
{
$address = $row['address'];
$county = $row['County'];
$country = $row['Country'];
}
mysqli_close($con);
<!DOCTYPE html>
<html>
<head>
<script type="text/javascript"
src="https://maps.googleapis.com/maps/api/js?
key=mykey&sensor=false">
</script>
<script type="text/javascript">
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var latlng = new google.maps.LatLng(
53.41291,-8.243889999999965);
var address = '<?php echo $address.', '.$country.', '.$county; ?
>';
var myOptions = {
zoom: 6,
center: latlng,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
map = new google.maps.Map(document.getElementById("map_canvas"),
myOptions);
geocoder.geocode( { 'address': address}, function(results,
status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
var marker = new google.maps.Marker({
map: map,
position: results[0].geometry.location
});
} else {
alert("Geocode was not successful for the following reason:
" + status);
}
});
}
</script>
</head>
<body onload="initialize()">
<div id="map_canvas" style="width:500px; height:500px"></div>
</body>
</html>