Last active
August 29, 2015 14:01
-
-
Save ebinnion/7ff42563ca63bb9bb6df to your computer and use it in GitHub Desktop.
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 | |
$listings = array( | |
array( | |
'address' => '3410 Taft Blvd', | |
'city' => 'Wichita Falls', | |
'state' => 'Tx', | |
'zip' => 76308 | |
) | |
); | |
foreach ( $listings as $listing ) { | |
$address = urlencode( "{$listings['address_1']} {$listings['city']} {$listings['state']} {$listings['zip']}" ); | |
$response = json_decode( wp_remote_retrieve_body( wp_remote_get("http://maps.googleapis.com/maps/api/geocode/json?address={$address}&sensor=false") ), true ); | |
$geometry = $response['results'][0]['geometry']; | |
if( 'OK' == $response['status'] ) { | |
?> | |
<iframe width="100%" height="300" style="border: 0;" src="https://www.google.com/maps/?f=q&source=s_q&hl=en&geocode=&q=<?php echo $address; ?>&t=m&ll=<?php echo $geometry['location']['lat'];?>, <?php echo $geometry['location']['lng'];?>&z=18&iwloc=&output=embed" frameborder="0"></iframe> | |
<a class="map" title="Get Directions" href="http://maps.google.com/maps?saddr=&daddr=<?php echo $address; ?>" target="_blank"> | |
<small>Click for Directions</small> | |
</a> | |
<?php | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment