Skip to content

Instantly share code, notes, and snippets.

@nmyers
Last active February 19, 2020 06:56
Show Gist options
  • Save nmyers/5d7360061ed4832e6a36 to your computer and use it in GitHub Desktop.
Save nmyers/5d7360061ed4832e6a36 to your computer and use it in GitHub Desktop.
ACF Static google map with link #acf #wp
<?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; ?>
@kriskhoury
Copy link

Thanks for this.

Wanted to add you have to enable "Maps Static API" in your GCP.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment