Skip to content

Instantly share code, notes, and snippets.

@schalkjoubert
Created February 7, 2018 18:44
Show Gist options
  • Save schalkjoubert/e118d0f55c9c62676d752a082694d06a to your computer and use it in GitHub Desktop.
Save schalkjoubert/e118d0f55c9c62676d752a082694d06a to your computer and use it in GitHub Desktop.
Testing for elevation from Google Map
<?php
/**
* Template used to display post content.
*
* @package storefront
*/
?>
<!-- https://www.bootply.com/L47vGoEops -->
<div class="col-lg-4 col-sm-6 col-xs-12 auction-archive-listing">
<article id="post-<?php the_ID(); ?>" class="flex-col" <?php post_class(); ?>>
<?php
/**
* Functions hooked in to storefront_loop_post action.
*
* @hooked storefront_post_header - 10
* @hooked storefront_post_meta - 20
* @hooked storefront_post_content - 30
* @hooked storefront_init_structured_data - 40
*/
//do_action( 'storefront_loop_post' );
?>
<header class="entry-header">
</header><!-- .entry-header -->
<div class="entry-content">
<?php
$url = "https://maps.googleapis.com/maps/api/elevation/json?locations=40.7143528,-74.0059731&key=AIzaSyCM1fCTYKPhk6tDCqsVNhcXto6aqjUc0yY";
$ch = curl_init();
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Disable SSL verification
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_URL,$url);
$result=curl_exec($ch);
curl_close($ch);
$result = str_replace(array("\n", "\r", "\t"), '', $result);
$result = trim(str_replace('"', "'", $result));
//print json_encode($result, JSON_PRETTY_PRINT);
//print json_encode($result, JSON_PRETTY_PRINT);
//$response = file_get_contents('https://maps.googleapis.com/maps/api/elevation/xml?locations=40.7143528,-74.0059731&key=AIzaSyCM1fCTYKPhk6tDCqsVNhcXto6aqjUc0yY');
//$results = new SimpleXMLElement($response);
echo $results->elevation;
?>
<?php if( get_field('auction_title') ): ?>
<span class='auction-content auction-stud'>
<h2><?php the_field( 'auction_title' ); ?></h2>
</span>
<?php endif; ?>
</div><!-- .entry-content -->
</article><!-- #post-## -->
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment