Created
September 21, 2015 20:58
-
-
Save MattSandy/d1b4a27874d364f07863 to your computer and use it in GitHub Desktop.
Checks if within a defined box based on longitude and latitude
This file contains hidden or 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 | |
$url = 'https://api.smartystreets.com/street-address?'; | |
$url .= 'auth-id=[auth-id]&auth-token=[auth-token]'; | |
$url .= '&street=' . $street . '&zipcode=' . $zip; | |
$urlData = json_decode(file_get_contents($url),true); | |
//print_r($urlData); | |
if(isset($urlData[0]['metadata']['latitude'])) { | |
$latitude = $urlData[0]['metadata']['latitude']; | |
$longitude = $urlData[0]['metadata']['longitude']; | |
//latitude check | |
if(($latitude<$latitudeTopLeft)&&($latitude>$latitudeBottomLeft)) { | |
//longitude check | |
if(($longitude>$longitudeTopLeft)&&($longitude<$longitudeTopRight)) { | |
$zone = true; | |
} | |
} | |
} | |
else { | |
$zone = false; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment