function gmap_geocode in GMap Module 7
Same name and namespace in other branches
- 5 gmap.module \gmap_geocode()
- 6.2 gmap.module \gmap_geocode()
- 6 gmap.module \gmap_geocode()
- 7.2 gmap.module \gmap_geocode()
Utility function to use the google maps geocoder server side. This is an easy, quick way to geocode a single address. Note: This is a REMOTE CALL TO GOOGLE. Do NOT use this where performance matters, as it could possibly take several seconds for this function to return. See http://www.google.com/apis/maps/documentation/reference.html#GGeoStatusCode for a description of the possible status codes.
1 string reference to 'gmap_geocode'
- gmap_location_update_5101 in ./
gmap_location.install - 5.x-1.0 update 2. (Post-release) Delete unneeded variable.
File
- ./
gmap.module, line 1198 - GMap -- Routines to use the Google Maps API in Drupal.
Code
function gmap_geocode($address, $tld = 'com') {
$key = gmap_get_key();
$data = drupal_http_request(gmap_views_protocol() . '://maps.google.' . $tld . '/maps/geo?q=' . urlencode($address) . '&output=csv&key=' . $key);
if ($data->code == 200) {
$r = explode(',', $data->data);
return array(
'status' => (int) $r[0],
'accuracy' => (int) $r[1],
'latitude' => $r[2],
'longitude' => $r[3],
);
}
// Non 200 is G_GEO_SERVER_ERROR (500).
return array(
'status' => 500,
);
}