diff --git a/openlayers_proximity.module b/openlayers_proximity.module index 65101d7..e638a9b 100644 --- a/openlayers_proximity.module +++ b/openlayers_proximity.module @@ -399,15 +399,24 @@ function openlayers_proximity_geocode($address) { $args['sensor'] = 'false'; $query = http_build_query($args, '', '&'); - if (function_exists("curl_init")) { - $ch = curl_init(); - curl_setopt($ch, CURLOPT_URL, OPENLAYERS_PROXIMITY_GOOGLE_GEOCODER_URL . $query); - curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); - $result = curl_exec($ch); - curl_close($ch); + $results = &drupal_static(__FUNCTION__); + + if (isset($results[$query])) { + $result = $results[$query]; } else { - $result = file_get_contents(OPENLAYERS_PROXIMITY_GOOGLE_GEOCODER_URL . $query); + if (function_exists("curl_init")) { + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, OPENLAYERS_PROXIMITY_GOOGLE_GEOCODER_URL . $query); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $result = curl_exec($ch); + curl_close($ch); + } + else { + $result = file_get_contents(OPENLAYERS_PROXIMITY_GOOGLE_GEOCODER_URL . $query); + } + + $results[$query] = $result; } $response = json_decode($result);