FIX гео-поиск в яндексе
This commit is contained in:
parent
f90dbddd33
commit
b805a7749c
|
|
@ -336,6 +336,7 @@ class JsonController extends Controller
|
||||||
|
|
||||||
$results = array();
|
$results = array();
|
||||||
if ($search) {
|
if ($search) {
|
||||||
|
App::log('searchQueries', $search);
|
||||||
// ====== POINTS ============
|
// ====== POINTS ============
|
||||||
$points = Point::model()->searchByString($search);
|
$points = Point::model()->searchByString($search);
|
||||||
if (!empty($points)) {
|
if (!empty($points)) {
|
||||||
|
|
@ -344,17 +345,16 @@ class JsonController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (count($results) < 10) {
|
if (count($results) < 10 && strlen($search) > 5) {
|
||||||
// ====== YANDEX ============
|
// ====== YANDEX ============
|
||||||
$ch = curl_init();
|
$ch = curl_init();
|
||||||
curl_setopt($ch, CURLOPT_URL, 'http://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($search));
|
curl_setopt($ch, CURLOPT_URL, 'https://geocode-maps.yandex.ru/1.x/?geocode=' . urlencode($search));
|
||||||
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
|
||||||
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
||||||
$out = null;
|
$out = null;
|
||||||
$out = curl_exec($ch);
|
$out = curl_exec($ch);
|
||||||
|
|
||||||
if (!empty($out)) {
|
if (!empty($out)) {
|
||||||
App::log('yandexSearch', $out);
|
|
||||||
$obj = simplexml_load_string($out);
|
$obj = simplexml_load_string($out);
|
||||||
|
|
||||||
if (isset($obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->found)) {
|
if (isset($obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->found)) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue