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() static function actionGeoCoding()
{ {
// ====== GOOGLE ============ // ====== GOOGLE ============
$lat = $lng = FALSE; // $lat = $lng = FALSE;
$search = isset($_GET['search']) ? $_GET['search'] : ''; // $search = isset($_GET['search']) ? $_GET['search'] : '';
//
$ch = curl_init(); // $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_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_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_REFERER, "http://wikipoints.ru"); // curl_setopt($ch, CURLOPT_REFERER, "http://wikipoints.ru");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$out = null; // $out = curl_exec($ch);
$out = curl_exec($ch); //App::log('geoCoding', $out);
//
if (!empty($out)) { // if (!empty($out)) {
$obj = json_decode($out); // $obj = json_decode($out);
if ((string) $obj->status == 'OK') { // if ((string) $obj->status == 'OK') {
$count = count($obj->results); // $count = count($obj->results);
if ($count > 0) { // if ($count > 0) {
$index = 0; // $index = 0;
$name = (string) $obj->results[$index]->formatted_address; // $name = (string) $obj->results[$index]->formatted_address;
$lat = (string) $obj->results[$index]->geometry->location->lat; // $lat = (string) $obj->results[$index]->geometry->location->lat;
$lng = (string) $obj->results[$index]->geometry->location->lng; // $lng = (string) $obj->results[$index]->geometry->location->lng;
} // }
} // }
} // }
curl_close($ch); // curl_close($ch);
//
$coords = array(); // $coords = array();
$coords['lat'] = $lat; // $coords['lat'] = $lat;
$coords['lng'] = $lng; // $coords['lng'] = $lng;
//
self::renderPartial('json.php', $coords); // self::renderPartial('json.php', $coords);
//
die; // die;
// ========== YANDEX ============= // ========== YANDEX =============
$address = isset($_GET['search']) ? $_GET['search'] : ''; $address = isset($_GET['search']) ? $_GET['search'] : '';

View File

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