From 310b5a64bb9385f12c6ff7f5a7042fb87b338838 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Sun, 28 Feb 2016 14:24:05 +0300 Subject: [PATCH] FIX - geo coding --- controllers/JsonController.php | 64 +++++++++++++++++----------------- public/js/suggest.js | 2 +- 2 files changed, 33 insertions(+), 33 deletions(-) diff --git a/controllers/JsonController.php b/controllers/JsonController.php index 1f22e97..d68da8a 100644 --- a/controllers/JsonController.php +++ b/controllers/JsonController.php @@ -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'] : ''; diff --git a/public/js/suggest.js b/public/js/suggest.js index 9aacb99..c1a2b66 100644 --- a/public/js/suggest.js +++ b/public/js/suggest.js @@ -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