From 18327ebbf05c484ab551b4b43964e34b082654e6 Mon Sep 17 00:00:00 2001 From: "Phyks (Lucas Verney)" Date: Thu, 21 Feb 2019 07:55:55 +0100 Subject: [PATCH] Fix polygon edition --- js/plugin/NogoAreas.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/js/plugin/NogoAreas.js b/js/plugin/NogoAreas.js index 15853e8..a70c63d 100644 --- a/js/plugin/NogoAreas.js +++ b/js/plugin/NogoAreas.js @@ -4,7 +4,7 @@ BR.NogoAreas = L.Control.extend({ MSG_BUTTON_CANCEL: 'Cancel drawing no-go area', MSG_CREATE: 'Click and drag to draw circle', MSG_DISABLED: 'Click to edit', - MSG_ENABLED: '□ = move / resize, = delete,
click circle to quit editing', + MSG_ENABLED: '□ = move / resize, = delete,
click nogo to quit editing', STATE_CREATE: 'no-go-create', STATE_CANCEL: 'cancel-no-go-create' }, @@ -116,7 +116,9 @@ BR.NogoAreas = L.Control.extend({ return { nogos: this.drawnItems.getLayers().filter(function (e) { return e instanceof L.Circle; }), polygons: this.drawnItems.getLayers().filter(function (e) { return e instanceof L.Polygon; }), - polylines: this.drawnItems.getLayers().filter(function (e) { return e instanceof L.Polyline; }), + polylines: this.drawnItems.getLayers().filter(function (e) { + return (e instanceof L.Polyline) && !(e instanceof L.Polygon); + }), }; }, @@ -226,7 +228,10 @@ BR.EditingTooltip = L.Handler.extend({ // works better with zooming than updating offset to match radius layer.openTooltip = function (layer, latlng) { if (!latlng && layer instanceof L.Layer) { - latlng = L.latLng(layer.getBounds().getSouth(), layer.getLatLng().lng); + latlng = L.latLng( + layer.getBounds().getSouth(), + 0.5 * (layer.getBounds().getWest() + layer.getBounds().getEast()) + ); } L.Layer.prototype.openTooltip.call(this, layer, latlng); };