FIX 2 - geo coding

This commit is contained in:
Krivchikov Dmitry 2016-02-28 14:31:20 +03:00
parent 310b5a64bb
commit 8383af2730
1 changed files with 31 additions and 32 deletions

View File

@ -365,38 +365,37 @@ 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 = 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;
// } $coords = array();
// } $coords['lat'] = $lat;
// } $coords['lng'] = $lng;
// curl_close($ch);
// self::renderPartial('json.php', $coords);
// $coords = array();
// $coords['lat'] = $lat; die;
// $coords['lng'] = $lng; }
// }
// self::renderPartial('json.php', $coords); }
// curl_close($ch);
// die;
// ========== YANDEX ============= // ========== YANDEX =============
$address = isset($_GET['search']) ? $_GET['search'] : ''; $address = isset($_GET['search']) ? $_GET['search'] : '';