Address in PHP variable, Google Maps embedding without Javascript?
You can use an iframe and pass the address as an URL parameter.
<iframe width="640" height="480" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="https://maps.google.it/maps?q=<?php echo $yourAddress; ?>&output=embed"></iframe>
You'll have to use the Geocoder API.
Here you go ( original can be found here ) :
<head>
...
<script src="https://maps.googleapis.com/maps/api/js?sensor=false"></script>
<script>
var geocoder;
var map;
function initialize() {
geocoder = new google.maps.Geocoder();
var mapOptions = {
zoom: 12, //Change the Zoom level to suit your needs
mapTypeId: google.maps.MapTypeId.ROADMAP
}
//map_canvas is just a <div> on the page with the id="map_canvas"
map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
//Your Variable Containing The Address
var address = "<?php echo $AddressVariable; ?>";
geocoder.geocode( { 'address': address}, function(results, status) {
if (status == google.maps.GeocoderStatus.OK) {
map.setCenter(results[0].geometry.location);
//places a marker on every 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>
Add this to the opening body
tag of your page to initialize the map:
<body onload="initialize()">
And here's the documentation for the Geocoder
class.