Exemplo n.º 1
0
 private function get_uk_postcode($postcode)
 {
     $return = false;
     $html = safe_scrape_cached("http://maps.google.com/maps?f=q&hl=en&geocode=&q=" . urlencode($postcode), CACHE_TIME_LONG);
     if ($html) {
         //$regex = '/geocode:\"(.*?),(.*?),(.*?)\"/';
         $regex = '/viewport:{center:{lat:(.*?),lng:(.*?)}/';
         preg_match_all($regex, $html, $matches, PREG_PATTERN_ORDER);
         if (isset($matches[2][0]) && isset($matches[1][0])) {
             $return = array($matches[2][0], $matches[1][0]);
         }
     }
     return $return;
 }
Exemplo n.º 2
0
function get_place_location($parts)
{
    //try the city search (for outside the us)
    $url = 'http://maps.google.com/maps/geo?key=' . GOOGLE_MAPS_KEY . '&output=csv&q=';
    $out = array();
    if (isset($parts['street'])) {
        $out[] = urlencode($parts['street']);
    }
    if (isset($parts['place'])) {
        $out[] = urlencode($parts['place']);
    }
    if (isset($parts['state'])) {
        $out[] = urlencode($parts['state']);
    }
    $out[] = urlencode($parts['country']);
    $url .= join(',+', $out);
    $data = safe_scrape_cached($url);
    return process_google_geocoder($data);
}