/** * Calls google to get longitude and latitude for location * This could be changed to use other mapping servcies. The file "map.js" would also have to be changed. * @param object $data Information get added to object * @return bool Whether call was successful */ function map_get_latlong(&$data, $map) { global $CFG; // Your Google Maps API key // Desired address $provider = map_get_map_provider($map); //$address = "$data->city,+$data->state,+$data->country"; // Translate Hebrew City name to English. will not work 100% of the time (nadavkav) try { $gt = new Gtranslate(); $heCityName = $gt->hebrew_to_english($data->city); } catch (GTranslateException $ge) { echo $ge->getMessage(); } $address = urlencode($heCityName) . "&country={$data->country}"; // Encode Hebrew translated to "Englished" city name (nadavkav) if (isset($data->address)) { $address = str_replace(" ", "+", ",{$data->address}+" . $address); } if ($provider == "google") { $address = urlencode($address); return map_get_latlong_google($data, $address); } else { return map_get_latlong_geonames($data, $address); } }