function set_from_postcode($zip, $country = 'UK')
 {
     //reset
     $this->reset();
     $success = false;
     $latlong = null;
     $country = strtolower($country);
     if ($country = 'uk') {
         $lnglat = $this->get_uk_postcode($zip);
     } else {
         //for outside UK, use google maps
         $lnglat = $this->call_google_geocoder(array($zip, $country));
         $lnglat = process_google_geocoder($data);
     }
     //set lat / long
     if (isset($lnglat) && $lnglat[0] != 0 && $lnglat[1] != 0) {
         $success = true;
         $this->lng = $lnglat[0];
         $this->lat = $lnglat[1];
     }
     return $success;
 }
Пример #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);
}