Exemplo n.º 1
0
 public static function drawMap($params = array())
 {
     // Manually load JS
     $content = "<script src='https://maps.googleapis.com/maps/api/js?signed_in=true&libraries=places,drawing,geometry'></script>";
     $content .= "<script src='" . content_url() . "/plugins/coverage_map/Views/Js/Map.js'></script>";
     $content .= "<script src='" . content_url() . "/plugins/coverage_map/Views/Js/AddressAutocomplete.js'></script>";
     $content .= "<script src='" . content_url() . "/plugins/coverage_map/Views/Js/AddressChecker.js'></script>";
     // Get options
     $options = CoverageMap_Libs_Manage::getStoredOptions();
     // Set some options from params
     $options->map->height = !empty($params['height']) ? $params['height'] : $options->map->height;
     $options->map->width = !empty($params['width']) ? $params['width'] : $options->map->width;
     // Render template
     $content .= CoverageMap_Libs_Helper::render(dirname(__FILE__) . "/../Views/Map.php", $options);
     echo $content;
 }
Exemplo n.º 2
0
 public static function check($address, $city, $state, $zip)
 {
     // Make request
     $answer = self::makeRequest($address, $city, $state, $zip);
     if (empty($answer)) {
         return false;
     }
     // Fetch data from request
     $meters = self::findMeters($answer);
     if ($meters == 0) {
         return false;
     }
     // Find speed by distance
     $options = CoverageMap_Libs_Manage::getStoredOptions();
     foreach ($options->zones as $i => $zone) {
         if ($meters <= $zone->radius || $i + 1 == count($options->zones)) {
             $speed = $zone->speed;
             break;
         }
     }
     return $speed;
 }