aboutsummaryrefslogtreecommitdiff
path: root/web/app/view/StateController.js
diff options
context:
space:
mode:
authorAbyss777 <abyss@fox5.ru>2017-11-08 15:04:43 +0500
committerAbyss777 <abyss@fox5.ru>2017-11-13 12:33:27 +0500
commitd93e45e176fc2cbba6525f100ef084d904baa1c1 (patch)
tree4b704e487600bda6c1604e39c1c1719962808525 /web/app/view/StateController.js
parentb36bb685ff31b06c7f50e660aebd3a69db5de5d7 (diff)
downloadtrackermap-web-d93e45e176fc2cbba6525f100ef084d904baa1c1.tar.gz
trackermap-web-d93e45e176fc2cbba6525f100ef084d904baa1c1.tar.bz2
trackermap-web-d93e45e176fc2cbba6525f100ef084d904baa1c1.zip
Implement geocoding retry
Diffstat (limited to 'web/app/view/StateController.js')
-rw-r--r--web/app/view/StateController.js28
1 files changed, 27 insertions, 1 deletions
diff --git a/web/app/view/StateController.js b/web/app/view/StateController.js
index 70f02281..44b01382 100644
--- a/web/app/view/StateController.js
+++ b/web/app/view/StateController.js
@@ -36,6 +36,9 @@ Ext.define('Traccar.view.StateController', {
deselectfeature: 'deselectFeature'
}
},
+ global: {
+ stategeocode: 'onGeocode'
+ },
store: {
'#LatestPositions': {
add: 'updateLatest',
@@ -48,7 +51,6 @@ Ext.define('Traccar.view.StateController', {
}
},
-
init: function () {
var i, hideAttributesPreference, attributesList;
if (Traccar.app.getUser().get('admin') ||
@@ -184,5 +186,29 @@ Ext.define('Traccar.view.StateController', {
this.position = null;
Ext.getStore('Attributes').removeAll();
}
+ },
+
+ onGeocode: function () {
+ var positionId = this.position.getId();
+ if (!this.position.get('address')) {
+ Ext.Ajax.request({
+ scope: this,
+ method: 'GET',
+ url: 'api/server/geocode',
+ params: {
+ latitude: this.position.get('latitude'),
+ longitude: this.position.get('longitude')
+ },
+ success: function (response) {
+ if (this.position && this.position.getId() === positionId) {
+ this.position.set('address', response.responseText);
+ this.updatePosition();
+ }
+ },
+ failure: function (response) {
+ Traccar.app.showError(response);
+ }
+ });
+ }
}
});