nakarte

Source code of https://map.sikmir.ru (fork)
git clone git://git.sikmir.ru/nakarte
Log | Files | Refs | LICENSE

commit 47919efaa9cfca602b7b3296fbd8f96975478aa7
parent f656854a6b698f4b7fa975076132bfc9cd73f2c2
Author: myadzel <myadzel@gmail.com>
Date:   Fri, 25 May 2018 12:22:58 +0300

relocate elevation closer, check for cursor out of range

Diffstat:
Msrc/lib/leaflet.control.elevation-profile/close.png | 0
Msrc/lib/leaflet.control.elevation-profile/elevation-profile.css | 6+++---
Msrc/lib/leaflet.control.elevation-profile/index.js | 16+++++++++++-----
3 files changed, 14 insertions(+), 8 deletions(-)

diff --git a/src/lib/leaflet.control.elevation-profile/close.png b/src/lib/leaflet.control.elevation-profile/close.png Binary files differ. diff --git a/src/lib/leaflet.control.elevation-profile/elevation-profile.css b/src/lib/leaflet.control.elevation-profile/elevation-profile.css @@ -44,7 +44,7 @@ position: relative; height: 100%; float: left; - width: 50px; + width: 35px; } .elevation-profile-drawingContainer { @@ -53,6 +53,7 @@ overflow-x: scroll; overflow-y: hidden; position: relative; + margin-right: 35px; } .elevation-profile-grid-label { @@ -163,8 +164,7 @@ .elevation-profile-close { position: absolute; - /*right: 0;*/ - left: 244px; + right: 10px; width: 16px; height: 16px; background-image: url("close.png"); diff --git a/src/lib/leaflet.control.elevation-profile/index.js b/src/lib/leaflet.control.elevation-profile/index.js @@ -457,9 +457,11 @@ const ElevationProfile = L.Class.extend({ this.drawingContainer.scrollLeft = newScrollLeft; this.cursorHide(); - this.setCursorPosition(ind); - this.cursorShow(); - this.updateGraphSelection(); + var positioned = this.setCursorPosition(ind); + if (positioned) { + this.cursorShow(); + this.updateGraphSelection(); + } }, @@ -624,7 +626,7 @@ const ElevationProfile = L.Class.extend({ setCursorPosition: function(ind) { if (!this._map || !this.values) { - return; + return false; } var distance = this.options.samplingInterval * ind; distance = (distance / 1000).toFixed(2); @@ -634,6 +636,9 @@ const ElevationProfile = L.Class.extend({ var x = Math.round(ind / (this.values.length - 1) * (this.svgWidth - 1)); var indInt = Math.round(ind); + if (indInt >= this.values.length) {//out of range + return false; + } var elevation = this.values[indInt]; this.graphCursorLabel.innerHTML = L.Util.template('{ele} m<br>{dist} km<br>{angle}&deg;', {ele: Math.round(elevation), dist: distance, grad: gradient, angle: angle} @@ -642,7 +647,7 @@ const ElevationProfile = L.Class.extend({ this.graphCursor.style.left = x + 'px'; this.graphCursorLabel.style.left = x + 'px'; if (this.drawingContainer.getBoundingClientRect().left - this.drawingContainer.scrollLeft + x + - this.graphCursorLabel.offsetWidth >= this._container.getBoundingClientRect().right) { + this.graphCursorLabel.offsetWidth >= this.drawingContainer.getBoundingClientRect().right) { L.DomUtil.addClass(this.graphCursorLabel, 'elevation-profile-cursor-label-left'); } else { L.DomUtil.removeClass(this.graphCursorLabel, 'elevation-profile-cursor-label-left'); @@ -665,6 +670,7 @@ const ElevationProfile = L.Class.extend({ ); this.setTrackMarkerLabel(label); + return true; }, onSvgMouseMove: function(e) {