Геокодирование
This commit is contained in:
parent
6e0dcc45b4
commit
7774157abd
|
|
@ -192,5 +192,22 @@ class JsonController extends Controller
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static function actionGeoCoding()
|
||||||
|
{
|
||||||
|
$address = isset($_GET['search']) ? $_GET['search'] : '';
|
||||||
|
|
||||||
|
$res = @file_get_contents('http://geocode-maps.yandex.ru/1.x/?format=json&geocode='.urlencode($address));
|
||||||
|
$res = json_decode($res, true);
|
||||||
|
|
||||||
|
if (isset ($res['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos']))
|
||||||
|
$point = explode (' ', $res['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos']);
|
||||||
|
else
|
||||||
|
$point = array(0, 0);
|
||||||
|
|
||||||
|
$coords = array();
|
||||||
|
$coords['lat'] = $point[1];
|
||||||
|
$coords['lng'] = $point[0];
|
||||||
|
|
||||||
|
self::renderPartial('json.php', $coords);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
<div class="glyphicon glyphicon-minus big _b" title="Отдалить" onclick="myMap.zoomOut()"></div>
|
<div class="glyphicon glyphicon-minus big _b" title="Отдалить" onclick="myMap.zoomOut()"></div>
|
||||||
|
|
||||||
<div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div>
|
<div class="glyphicon glyphicon-globe _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"></div>
|
||||||
|
<div class="glyphicon glyphicon-filter _c boxButtonFilter" title="Фильтры" onclick="openBox('Filter')"></div>
|
||||||
<div class="glyphicon glyphicon-flag _b" title="Я на карте" onclick="showMeOnTheMap()"></div>
|
<div class="glyphicon glyphicon-flag _b" title="Я на карте" onclick="showMeOnTheMap()"></div>
|
||||||
<div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div>
|
<div class="glyphicon glyphicon-list boxButtonRoute" title="Маршрут" onclick="openBox('Route')"></div>
|
||||||
|
|
||||||
|
|
@ -26,7 +27,13 @@
|
||||||
<a onclick="$('#howToUseModal').modal('show');" href="#">Как пользоваться</a><br/>
|
<a onclick="$('#howToUseModal').modal('show');" href="#">Как пользоваться</a><br/>
|
||||||
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a><br/>
|
<a onclick="$('#categoriesModal').modal('show');" href="#">Легенда</a><br/>
|
||||||
<a href="/page/points">Список точек</a><br/>
|
<a href="/page/points">Список точек</a><br/>
|
||||||
<br/>
|
</div>
|
||||||
|
<div id="boxLayers">
|
||||||
|
<h3>Карты</h3>
|
||||||
|
Layers
|
||||||
|
</div>
|
||||||
|
<div id="boxFilter">
|
||||||
|
<h3>Фильтры и поиск</h3>
|
||||||
<span class="input-group">
|
<span class="input-group">
|
||||||
<input type="text" id="addressField" class="form-control" placeholder="Поиск на карте..." onkeydown="if(event.keyCode == 13) {searchAdderess()}" />
|
<input type="text" id="addressField" class="form-control" placeholder="Поиск на карте..." onkeydown="if(event.keyCode == 13) {searchAdderess()}" />
|
||||||
<span class="input-group-btn">
|
<span class="input-group-btn">
|
||||||
|
|
@ -34,10 +41,6 @@
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
<div id="boxLayers">
|
|
||||||
<h3>Карты</h3>
|
|
||||||
Layers
|
|
||||||
</div>
|
|
||||||
<div id="boxRoute">
|
<div id="boxRoute">
|
||||||
<h3>Маршрут</h3>
|
<h3>Маршрут</h3>
|
||||||
<div id="wayPoints"></div>
|
<div id="wayPoints"></div>
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
html {height: 100%;}
|
html {height: 100%;}
|
||||||
body {margin: 0; padding: 0; height: 100%;}
|
body {margin: 0; padding: 0; height: 100%; width: 100%; overflow: hidden;}
|
||||||
div#map {width: 100%; position: absolute; top: 0; bottom: 0px;}
|
div#map {width: 100%; position: absolute; top: 0; bottom: 0px;}
|
||||||
body.openBox div#map {right: 250px;}
|
body.openBox div#map {right: 250px;}
|
||||||
div.infoCard h3 {text-align: center; margin-top: 0;}
|
div.infoCard h3 {text-align: center; margin-top: 0;}
|
||||||
|
|
@ -20,7 +20,7 @@ div.add {cursor: pointer;}
|
||||||
.form-group.has-error .error {display: inline-block;}
|
.form-group.has-error .error {display: inline-block;}
|
||||||
|
|
||||||
#wayPoints {margin-bottom: 10px;}
|
#wayPoints {margin-bottom: 10px;}
|
||||||
#wayPoints .wayPoint {cursor: pointer; border: solid 1px #999; padding: 2px 5px; margin-bottom: 3px;}
|
#wayPoints .wayPoint {cursor: pointer; border: solid 1px #999; padding: 2px 5px; margin-bottom: 3px; background-color: #fff;}
|
||||||
#wayPoints .wayPoint span {font-weight: bold; color: red;}
|
#wayPoints .wayPoint span {font-weight: bold; color: red;}
|
||||||
|
|
||||||
#routes {margin-bottom: 10px; height: 200px; background-color: #ff9999;}
|
#routes {margin-bottom: 10px; height: 200px; background-color: #ff9999;}
|
||||||
|
|
@ -44,7 +44,8 @@ body.openBox div#box {display: block;}
|
||||||
div#box {width: 250px; display: none; position: absolute; top: 0; right: 0;bottom: 0px; border-left: 2px solid rgba(45, 45, 45, 0.8); padding: 0 7px;}
|
div#box {width: 250px; display: none; position: absolute; top: 0; right: 0;bottom: 0px; border-left: 2px solid rgba(45, 45, 45, 0.8); padding: 0 7px;}
|
||||||
div#box #boxClose {position: absolute; right: 7px; top: 7px; color: #999; font-size: 18px; font-weight: bolder; cursor: pointer;}
|
div#box #boxClose {position: absolute; right: 7px; top: 7px; color: #999; font-size: 18px; font-weight: bolder; cursor: pointer;}
|
||||||
div#box div {display: none;}
|
div#box div {display: none;}
|
||||||
div#box div > div{display: block;}
|
div#box div div{display: block;}
|
||||||
|
div#box h3 {margin-top: 10px;}
|
||||||
|
|
||||||
/*Leaflet FIX*/
|
/*Leaflet FIX*/
|
||||||
.leaflet-popup-content-wrapper .leaflet-popup-scrolled {border-bottom: none;border-top: none;}
|
.leaflet-popup-content-wrapper .leaflet-popup-scrolled {border-bottom: none;border-top: none;}
|
||||||
|
|
@ -287,16 +287,26 @@ function initCategories()
|
||||||
*/
|
*/
|
||||||
function searchAdderess()
|
function searchAdderess()
|
||||||
{
|
{
|
||||||
var myGeocoder = ymaps.geocode($('#addressField').val());
|
$.ajax({
|
||||||
myGeocoder.then(
|
url: "/json/geocoding",
|
||||||
function(res) {
|
data: {
|
||||||
search = new ymaps.Placemark(res.geoObjects.get(0).geometry.getCoordinates());
|
search: $('#addressField').val()
|
||||||
myMap.geoObjects.add(search);
|
},
|
||||||
myMap.setCenter(res.geoObjects.get(0).geometry.getCoordinates(), 10);
|
success: function(data)
|
||||||
},
|
{
|
||||||
function(err) {
|
if (data.lat && data.lng)
|
||||||
|
{
|
||||||
|
myMap.setView([data.lat, data.lng], 13);
|
||||||
|
L.popup()
|
||||||
|
.setLatLng([data.lat, data.lng])
|
||||||
|
.setContent('Координаты: lat:'+data.lat+' lng:'+data.lng)
|
||||||
|
.openOn(myMap);
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
alert('Ничего не найдено.');
|
||||||
}
|
}
|
||||||
);
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue