Last active
February 19, 2020 06:56
-
-
Save nmyers/5d7360061ed4832e6a36 to your computer and use it in GitHub Desktop.
ACF Static google map with link #acf #wp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$location = get_field('location'); | |
if( !empty($location) ): | |
?> | |
<a href="http://www.google.com/maps/preview#!q=<?=urlencode( $location['address'] )?>"> | |
<img src="http://maps.googleapis.com/maps/api/staticmap?center=<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>&zoom=15&format=png&sensor=false&size=397x297&maptype=roadmap&visual_refresh=true&style=visibility:off&style=feature:road|element:geometry|visibility:simplified&style=feature:landscape|element:geometry|visibility:simplified&style=element:labels|visibility:on&markers=color:red|<?php echo $location['lat']; ?>,<?php echo $location['lng']; ?>"/> | |
</a> | |
<?php endif; ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this.
Wanted to add you have to enable "Maps Static API" in your GCP.