Ещё один вариант попытки исправить ситуацию с определением положения пользователя.
This commit is contained in:
parent
834360af7d
commit
e7f19c2ac6
|
|
@ -7,34 +7,49 @@ var intervalId = null;
|
||||||
* Пытается более точно определить координаты пользователя на карте и, при необходимости, обновляет положение точки "im"
|
* Пытается более точно определить координаты пользователя на карте и, при необходимости, обновляет положение точки "im"
|
||||||
* @returns {undefined}
|
* @returns {undefined}
|
||||||
*/
|
*/
|
||||||
function showMeOnTheMap(interval)
|
function showMeOnTheMap() {
|
||||||
{
|
if (navigator.geolocation) {
|
||||||
// TODO: Продумать ещё раз и переписать
|
navigator.geolocation.getCurrentPosition(
|
||||||
// if (!interval) {
|
geolocationSuccess,
|
||||||
// if (showMeTimerOn) {
|
geolocationFailure,
|
||||||
// clearInterval(intervalId);
|
{
|
||||||
// intervalId = null;
|
enableHighAccuracy: true,
|
||||||
// showMeTimerOn = false;
|
timeout: 5000,
|
||||||
// $('#showMeOnTheMap').removeClass('active');
|
maximumAge: 60000
|
||||||
// } else {
|
}
|
||||||
// if (showMeLastTime + 10 >= getTime() && !showMeTimerOn) {
|
);
|
||||||
// showMeTimerOn = true;
|
}
|
||||||
// $('#showMeOnTheMap').addClass('active');
|
else {
|
||||||
// intervalId = setInterval('showMeOnTheMap(true)', 15000);
|
alert('Error');
|
||||||
// showMeLastTime = getTime();
|
}
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// showMeLastTime = getTime();
|
|
||||||
// }
|
|
||||||
|
|
||||||
navigator.geolocation.getCurrentPosition(function (pos) {
|
|
||||||
coords = [pos.coords.latitude, pos.coords.longitude];
|
|
||||||
$.cookie('userLat',pos.coords.latitude);
|
|
||||||
$.cookie('userLng',pos.coords.longitude);
|
|
||||||
myMap.removeLayer(points.im);
|
|
||||||
points.im.setLatLng(coords).addTo(myMap);
|
|
||||||
myMap.setView(coords, myMap.getZoom());
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function geolocationSuccess(pos) {
|
||||||
|
coords = [pos.coords.latitude, pos.coords.longitude];
|
||||||
|
$.cookie('userLat',pos.coords.latitude);
|
||||||
|
$.cookie('userLng',pos.coords.longitude);
|
||||||
|
myMap.removeLayer(points.im);
|
||||||
|
points.im.setLatLng(coords).addTo(myMap);
|
||||||
|
myMap.setView(coords, myMap.getZoom());
|
||||||
|
}
|
||||||
|
|
||||||
|
function geolocationFailure(positionError) {
|
||||||
|
if(positionError == 1) {
|
||||||
|
text = "Вы решили не предоставлять данные о своем местоположении, " +
|
||||||
|
"но это не проблема. Мы больше не будем запрашивать их у вас.";
|
||||||
|
}
|
||||||
|
else if(positionError == 2) {
|
||||||
|
text = "Проблемы с сетью или нельзя связаться со службой определения " +
|
||||||
|
"местоположения по каким-либо другим причинам.";
|
||||||
|
}
|
||||||
|
else if(positionError == 3) {
|
||||||
|
text = "He удалось определить местоположение "
|
||||||
|
+ "в течение установленного времени. ";
|
||||||
|
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
text = 'Ошибка при определении координат. #' + positionError;
|
||||||
|
}
|
||||||
|
|
||||||
|
alert(text);
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ if (App::$user) {
|
||||||
|
|
||||||
<div class="glyphicon _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"><img src="/img/buttons/layers.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
<div class="glyphicon _t boxButtonLayers" onclick="openBox('Layers')" title="Слои карты"><img src="/img/buttons/layers.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
||||||
<div class="glyphicon _c boxButtonFilter" title="Фильтры и поиск" onclick="openBox('Filter')"><img src="/img/buttons/search.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
<div class="glyphicon _c boxButtonFilter" title="Фильтры и поиск" onclick="openBox('Filter')"><img src="/img/buttons/search.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
||||||
<div class="glyphicon _c" id="showMeOnTheMap" title="Я на карте" onclick="showMeOnTheMap(false)"><img src="/img/buttons/myPosition.png" style="margin-top: -20px; height: 21px;" /></div>
|
<div class="glyphicon _c" id="showMeOnTheMap" title="Я на карте" onclick="showMeOnTheMap()"><img src="/img/buttons/myPosition.png" style="margin-top: -20px; height: 21px;" /></div>
|
||||||
<div class="glyphicon _b boxButtonRoute" title="Маршрут" onclick="openBox('Route')"><img src="/img/buttons/route.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
<div class="glyphicon _b boxButtonRoute" title="Маршрут" onclick="openBox('Route')"><img src="/img/buttons/route.png" style="margin-top: -10px; margin-left: -5px; width: 30px;" /></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue