diff options
Diffstat (limited to 'web/app/view/GeofenceMap.js')
-rw-r--r-- | web/app/view/GeofenceMap.js | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/web/app/view/GeofenceMap.js b/web/app/view/GeofenceMap.js index 2538a8b16..e8a4dc5de 100644 --- a/web/app/view/GeofenceMap.js +++ b/web/app/view/GeofenceMap.js @@ -28,9 +28,12 @@ Ext.define('Traccar.view.GeofenceMap', { tbar: { items: [{ xtype: 'combobox', - store: 'GeozoneTypes', - valueField: 'id', - displayField: 'name' + store: 'GeofenceTypes', + valueField: 'key', + displayField: 'name', + listeners: { + select: 'onTypeSelect' + } }, { xtype: 'tbfill' }, { @@ -42,6 +45,10 @@ Ext.define('Traccar.view.GeofenceMap', { }] }, + getFeatures: function () { + return this.features; + }, + initMap: function () { var map, featureOverlay; this.callParent(); @@ -79,15 +86,21 @@ Ext.define('Traccar.view.GeofenceMap', { })); }, - addInteraction: function () { + addInteraction: function (type) { this.draw = new ol.interaction.Draw({ features: this.features, - type: 'Polygon' // (typeSelect.value) + type: type }); + this.draw.on('drawstart', function () { + this.features.clear(); + }, this); this.map.addInteraction(this.draw); }, removeInteraction: function () { - this.map.removeInteraction(this.draw); + if (this.draw) { + this.map.removeInteraction(this.draw); + this.draw = null; + } } }); |