From 77570db7a80f8acb6f7760eafa32563a16ba3f88 Mon Sep 17 00:00:00 2001 From: Krivchikov Dmitry Date: Sun, 29 May 2016 10:34:00 +0300 Subject: [PATCH] =?UTF-8?q?ADD=20=D0=B2=D1=8B=D0=B2=D0=BE=D0=B4=20=D0=B4?= =?UTF-8?q?=D0=BB=D0=B8=D0=BD=D1=8B=20=D1=82=D1=80=D0=B5=D0=BA=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- classes/Geo.php | 5 ++++- models/Trips.php | 4 ++++ public/js/map.js | 1 + public/js/tracks.js | 2 +- views/indexTemplate.php | 1 + 5 files changed, 11 insertions(+), 2 deletions(-) diff --git a/classes/Geo.php b/classes/Geo.php index 89b894c..c70e328 100644 --- a/classes/Geo.php +++ b/classes/Geo.php @@ -17,7 +17,10 @@ class Geo $delta_lng = ($lng2 - $lng1); return (6378137 * acos(cos($lat1) * cos($lat2) * cos($lng1 - $lng2) + sin($lat1) * sin($lat2))); -// return round(6378137 * acos(cos($lat1) * cos($lat2) * cos($lng1 - $lng2) + sin($lat1) * sin($lat2))); } + static function formatedDistance($distance) + { + return $distance > 1000 ? round($distance/1000, 2).'km' : round($distance).'m'; + } } diff --git a/models/Trips.php b/models/Trips.php index 97e46a7..d06ff87 100644 --- a/models/Trips.php +++ b/models/Trips.php @@ -18,4 +18,8 @@ class Trips extends Model return new self(); } + function getDistance() + { + return Geo::formatedDistance($this->distance); + } } diff --git a/public/js/map.js b/public/js/map.js index ba2c910..8c1b2bd 100644 --- a/public/js/map.js +++ b/public/js/map.js @@ -244,6 +244,7 @@ function initPoints(useBounds) } else if (getURLParameter('track') != 'null') { showTrack(getURLParameter('track')) + $('#trackShowHide' + getURLParameter('track')).prop('checked', true); } } }); diff --git a/public/js/tracks.js b/public/js/tracks.js index 10185b7..0dac8e7 100644 --- a/public/js/tracks.js +++ b/public/js/tracks.js @@ -40,7 +40,7 @@ function hideTrack(id) function loadTrack(id) { - colors = ['#e93333', '#fea22e', '#ff0', '#0f0', '#4267de', '#e42086', '#333']; + colors = ['#ff0000', '#ff8e00', '#ff0', '#0f0', '#003cff', '#ff00ad']; colorIndex = 0; tracks = new Array(); markers = new Array(); diff --git a/views/indexTemplate.php b/views/indexTemplate.php index 9b80ad3..d26ac4c 100644 --- a/views/indexTemplate.php +++ b/views/indexTemplate.php @@ -116,6 +116,7 @@ if (App::$user) {
name ?> + getDistance(); ?> status == Trips::STATUS_PUBLIC):?> [клик правой кнопкой -> копировать адрес]">