FIX - geo coding

This commit is contained in:
Krivchikov Dmitry 2016-02-28 14:24:05 +03:00
parent 6fbd944417
commit 310b5a64bb
2 changed files with 33 additions and 33 deletions

View File

@ -365,38 +365,38 @@ class JsonController extends Controller
static function actionGeoCoding()
{
// ====== GOOGLE ============
$lat = $lng = FALSE;
$search = isset($_GET['search']) ? $_GET['search'] : '';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/geocode/json?language=ru&key=AIzaSyDuWmguxO35oV9WGc6D8xUPvQBaUS4kt78&address=' . urlencode($search));
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_REFERER, "http://wikipoints.ru");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = null;
$out = curl_exec($ch);
if (!empty($out)) {
$obj = json_decode($out);
if ((string) $obj->status == 'OK') {
$count = count($obj->results);
if ($count > 0) {
$index = 0;
$name = (string) $obj->results[$index]->formatted_address;
$lat = (string) $obj->results[$index]->geometry->location->lat;
$lng = (string) $obj->results[$index]->geometry->location->lng;
}
}
}
curl_close($ch);
$coords = array();
$coords['lat'] = $lat;
$coords['lng'] = $lng;
self::renderPartial('json.php', $coords);
die;
// $lat = $lng = FALSE;
// $search = isset($_GET['search']) ? $_GET['search'] : '';
//
// $ch = curl_init();
// curl_setopt($ch, CURLOPT_URL, 'https://maps.googleapis.com/maps/api/geocode/json?language=ru&key=AIzaSyDuWmguxO35oV9WGc6D8xUPvQBaUS4kt78&address=' . urlencode($search));
// curl_setopt($ch, CURLOPT_TIMEOUT, 3);
// curl_setopt($ch, CURLOPT_REFERER, "http://wikipoints.ru");
// curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
// $out = curl_exec($ch);
//App::log('geoCoding', $out);
//
// if (!empty($out)) {
// $obj = json_decode($out);
// if ((string) $obj->status == 'OK') {
// $count = count($obj->results);
// if ($count > 0) {
// $index = 0;
// $name = (string) $obj->results[$index]->formatted_address;
// $lat = (string) $obj->results[$index]->geometry->location->lat;
// $lng = (string) $obj->results[$index]->geometry->location->lng;
// }
// }
// }
// curl_close($ch);
//
// $coords = array();
// $coords['lat'] = $lat;
// $coords['lng'] = $lng;
//
// self::renderPartial('json.php', $coords);
//
// die;
// ========== YANDEX =============
$address = isset($_GET['search']) ? $_GET['search'] : '';

View File

@ -39,10 +39,10 @@ function suggestKeyPress(key)
//ENTER
if ( $('div.hover','#suggestContainer').length > 0 ) {
link = $('a', $('div.hover','#suggestContainer')).attr('href');
window.location.href = link;
} else {
searchAdderess();
}
window.location.href = link;
break
case 38:
//UP