The Location Field add-on for Advanced Custom Fields lets you easily create a backend field for users specifying an address. This code allows you to display that address as a static google map.
<?php | |
$location = get_post_meta( get_the_ID(), 'be_address', true ); | |
echo '<p><a href="https://www.google.com/maps/place/' . urlencode( $location['address'] ) . '"><img src="http://maps.googleapis.com/maps/api/staticmap?center=' . urlencode( $location['lat'] . ',' . $location['lng'] ). '&zoom=13&size=167x171&maptype=roadmap&sensor=false&markers=color:red%7C' . $location['lat'] . ',' . $location['lng'] . '" /></a></p>'; |
Result: