ADD гео-кодирование через Google; FIX поиск по координатам в Яндекс
This commit is contained in:
parent
3face5f2f4
commit
4e08b64a01
|
|
@ -94,7 +94,7 @@ class JsonController extends Controller
|
|||
*/
|
||||
static function actionCategories()
|
||||
{
|
||||
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true, 'asArrayOf' => true));
|
||||
$categories = Category::model()->getAll(array('order' => 'ord ASC', 'asArray' => true, 'noKeys' => true));
|
||||
|
||||
self::renderPartial('json.php', array(
|
||||
'data' => $categories,
|
||||
|
|
@ -372,6 +372,39 @@ class JsonController extends Controller
|
|||
$lng = $coords[0];
|
||||
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
|
||||
}
|
||||
} else if (isset($obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->Point)) {
|
||||
$coords = explode(' ', (string) $obj->GeoObjectCollection->metaDataProperty->GeocoderResponseMetaData->Point->pos);
|
||||
$lat = $coords[1];
|
||||
$lng = $coords[0];
|
||||
$name = "Координаты N°" . $lat . ' E°' . $lng;
|
||||
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
|
||||
}
|
||||
}
|
||||
}
|
||||
curl_close($ch);
|
||||
}
|
||||
|
||||
if (count($results) < 10 && strlen($search) > 5) {
|
||||
// ====== GOOGLE ============
|
||||
$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) {
|
||||
for ($index = 0; $index < $count && $index < 5 && count($results) < 25; $index++) {
|
||||
$name = (string) $obj->results[$index]->formatted_address;
|
||||
$lat = (string) $obj->results[$index]->geometry->location->lat;
|
||||
$lng = (string) $obj->results[$index]->geometry->location->lng;
|
||||
$results[] = array('value' => $name, 'data' => "/?lat=$lat&lng=$lng&zoom=13");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -423,10 +456,10 @@ class JsonController extends Controller
|
|||
self::renderPartial('json.php', array(
|
||||
'data' => ArticlePhotos::model()->getAll(
|
||||
array(
|
||||
'where'=>'`owner` = '.(int) App::$user->id,
|
||||
'where' => '`owner` = ' . (int) App::$user->id,
|
||||
'order' => '`id` DESC',
|
||||
'asArray'=>true,
|
||||
'noKeys'=>true
|
||||
'asArray' => true,
|
||||
'noKeys' => true
|
||||
)
|
||||
)
|
||||
));
|
||||
|
|
|
|||
Loading…
Reference in New Issue