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.
Updated code - an API key is required nowadays. You may need to urlencode the address but it should even work without it:
<iframe width="600" height="450" frameborder="0" style="border:0" src="https://www.google.com/maps/embed/v1/place?key=API_KEY &q=<?php echo $address; ?>" allowfullscreen></iframe>
Source: https://developers.google.com/maps/documentation/embed/get-started