Новый гео-кодер про Enter
This commit is contained in:
parent
7601d27a97
commit
8314d78f1b
|
|
@ -376,6 +376,41 @@ class JsonController extends Controller
|
||||||
|
|
||||||
static function actionGeoCoding()
|
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;
|
||||||
|
|
||||||
|
// ========== YANDEX =============
|
||||||
$address = isset($_GET['search']) ? $_GET['search'] : '';
|
$address = isset($_GET['search']) ? $_GET['search'] : '';
|
||||||
|
|
||||||
$res = @file_get_contents('http://geocode-maps.yandex.ru/1.x/?format=json&geocode=' . urlencode($address));
|
$res = @file_get_contents('http://geocode-maps.yandex.ru/1.x/?format=json&geocode=' . urlencode($address));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue