diff options
-rw-r--r-- | src/org/traccar/protocol/Tk103ProtocolDecoder.java | 14 | ||||
-rw-r--r-- | web/app/view/MapController.js | 2 | ||||
-rw-r--r-- | web/app/view/ReportController.js | 34 |
3 files changed, 30 insertions, 20 deletions
diff --git a/src/org/traccar/protocol/Tk103ProtocolDecoder.java b/src/org/traccar/protocol/Tk103ProtocolDecoder.java index 9512910f2..36378d088 100644 --- a/src/org/traccar/protocol/Tk103ProtocolDecoder.java +++ b/src/org/traccar/protocol/Tk103ProtocolDecoder.java @@ -170,10 +170,16 @@ public class Tk103ProtocolDecoder extends BaseProtocolDecoder { position.setLatitude(parser.nextCoordinate()); position.setLongitude(parser.nextCoordinate()); - if (Context.getConfig().getBoolean(getProtocolName() + ".mph")) { - position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); - } else { - position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); + switch (Context.getConfig().getString(getProtocolName() + ".speed", "kmh")) { + case "kn": + position.setSpeed(parser.nextDouble()); + break; + case "mph": + position.setSpeed(UnitsConverter.knotsFromMph(parser.nextDouble())); + break; + default: + position.setSpeed(UnitsConverter.knotsFromKph(parser.nextDouble())); + break; } dateBuilder.setTime(parser.nextInt(), parser.nextInt(), parser.nextInt()); diff --git a/web/app/view/MapController.js b/web/app/view/MapController.js index b8b7290b8..eee74099f 100644 --- a/web/app/view/MapController.js +++ b/web/app/view/MapController.js @@ -176,6 +176,8 @@ Ext.define('Traccar.view.MapController', { this.reportRoute.getGeometry().appendCoordinate(point); } + + this.getView().getMapView().fit(this.reportRoute.getGeometry(), this.getView().getMap().getSize()); }, clearReport: function (store) { diff --git a/web/app/view/ReportController.js b/web/app/view/ReportController.js index 9c2abcc71..4fe7c62b8 100644 --- a/web/app/view/ReportController.js +++ b/web/app/view/ReportController.js @@ -37,25 +37,27 @@ Ext.define('Traccar.view.ReportController', { fromDate = this.lookupReference('fromDateField').getValue(); fromTime = this.lookupReference('fromTimeField').getValue(); - from = new Date( - fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(), - fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds()); + if (deviceId) { + from = new Date( + fromDate.getFullYear(), fromDate.getMonth(), fromDate.getDate(), + fromTime.getHours(), fromTime.getMinutes(), fromTime.getSeconds(), fromTime.getMilliseconds()); - toDate = this.lookupReference('toDateField').getValue(); - toTime = this.lookupReference('toTimeField').getValue(); + toDate = this.lookupReference('toDateField').getValue(); + toTime = this.lookupReference('toTimeField').getValue(); - to = new Date( - toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), - toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); + to = new Date( + toDate.getFullYear(), toDate.getMonth(), toDate.getDate(), + toTime.getHours(), toTime.getMinutes(), toTime.getSeconds(), toTime.getMilliseconds()); - store = Ext.getStore('Positions'); - store.load({ - params: { - deviceId: deviceId, - from: from.toISOString(), - to: to.toISOString() - } - }); + store = Ext.getStore('Positions'); + store.load({ + params: { + deviceId: deviceId, + from: from.toISOString(), + to: to.toISOString() + } + }); + } }, onClearClick: function () { |