diff --git a/ground/controllers/IndexController.php b/ground/controllers/IndexController.php index 1d0dd3f..7c0ff59 100644 --- a/ground/controllers/IndexController.php +++ b/ground/controllers/IndexController.php @@ -27,6 +27,7 @@ class IndexController extends Controller self::addScript('/js/leaflet.markercluster.js'); self::addScript('/js/fotorama.js'); self::addScript('/js/suggest.js?ver=' . App::getConfig('version')); + self::addScript('/js/navigation.js?ver=' . App::getConfig('version')); self::addStyle('/css/style.css?ver=' . App::getConfig('version')); self::addStyle('http://cdn.leafletjs.com/leaflet-0.7.3/leaflet.css'); diff --git a/ground/views/indexTemplate.php b/ground/views/indexTemplate.php index 6a43193..b77764d 100644 --- a/ground/views/indexTemplate.php +++ b/ground/views/indexTemplate.php @@ -7,7 +7,7 @@
-
+
diff --git a/public/css/style.css b/public/css/style.css index 747c861..d33016b 100644 --- a/public/css/style.css +++ b/public/css/style.css @@ -53,7 +53,8 @@ div.leaflet-popup-content button:hover span.label {display: inline;} /*Controls for BOX*/ div#control {width: 50px; position: absolute; top: 0; right: 0;bottom: 50px; color: white; font-size: 20px; padding-top: 10px;} body.openBox div#control {right: 250px;} -div#control div {background-color: rgba(15, 15, 15, 0.65); border-radius: 8px 0 0 8px; width: auto; padding: 10px; margin-left: 10px; margin-bottom: 8px;} +div#control div {background-color: rgba(15, 15, 15, 0.65); border-radius: 8px 0 0 8px; width: auto; padding: 10px; margin-left: 10px; margin-bottom: 8px; cursor: pointer;} +div#control div:before {cursor: pointer;} div#control div:hover {background-color: #000;} div#control div.active {background-color: rgb(255, 162, 0);} div#control div.big {font-size: 22px; padding: 14px; margin-left: 0;} diff --git a/public/js/app.js b/public/js/app.js index 92c20e3..da349d8 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -166,3 +166,7 @@ window.addEventListener('popstate', function(e) } } }, false); + +function getTime() { + return Math.floor(Date.now() / 1000); +} diff --git a/public/js/map.js b/public/js/map.js index d9d0b62..699bf09 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -304,20 +304,6 @@ function searchAdderess() }); } -/** - * Пытается более точно определить координаты пользователя на карте и, при необходимости, обновляет положение точки "im" - * @returns {undefined} - */ -function showMeOnTheMap() -{ - navigator.geolocation.getCurrentPosition(function (pos) { - coords = [pos.coords.latitude, pos.coords.longitude]; - myMap.removeLayer(points.im); - points.im.setLatLng(coords).addTo(myMap); - myMap.setView(coords, defaultZoom); - }); -} - /** * Активирет добавление точки - ждёт выбор координат, меняет курсор на прицел. * @returns {Boolean} diff --git a/public/js/navigation.js b/public/js/navigation.js new file mode 100644 index 0000000..38fb613 --- /dev/null +++ b/public/js/navigation.js @@ -0,0 +1,37 @@ +var showMeLastTime = 0; +var showMeTimerOn = false; +var intervalId = null; + + +/** + * Пытается более точно определить координаты пользователя на карте и, при необходимости, обновляет положение точки "im" + * @returns {undefined} + */ +function showMeOnTheMap(interval) +{ + if (!interval) { + if (showMeTimerOn) { + clearInterval(intervalId); + intervalId = null; + showMeTimerOn = false; + $('#showMeOnTheMap').removeClass('active'); + } else { + if (showMeLastTime + 10 >= getTime() && !showMeTimerOn) { + showMeTimerOn = true; + $('#showMeOnTheMap').addClass('active'); + intervalId = setInterval('showMeOnTheMap(true)', 15000); + showMeLastTime = getTime(); + } + } + showMeLastTime = getTime(); + } + + navigator.geolocation.getCurrentPosition(function (pos) { + coords = [pos.coords.latitude, pos.coords.longitude]; + myMap.removeLayer(points.im); + points.im.setLatLng(coords).addTo(myMap); + myMap.setView(coords, myMap.getZoom()); + }); +} + +