From ebb43a1d910595462b384e3d1bd6375672da5b84 Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 3 Jul 2016 20:03:23 +1200 Subject: Implement geofence saving --- web/app/view/GeofenceMap.js | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) (limited to 'web/app/view/GeofenceMap.js') 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; + } } }); -- cgit v1.2.3