diff --git a/umap/static/umap/js/umap.controls.js b/umap/static/umap/js/umap.controls.js index 2ca538b9..af4e096a 100644 --- a/umap/static/umap/js/umap.controls.js +++ b/umap/static/umap/js/umap.controls.js @@ -1198,7 +1198,7 @@ L.U.Editable = L.Editable.extend({ initialize: function (map, options) { L.Editable.prototype.initialize.call(this, map, options); - this.on('editable:drawing:start editable:drawing:click', this.drawingTooltip); + this.on('editable:drawing:start editable:drawing:click editable:drawing:move', this.drawingTooltip); this.on('editable:drawing:end', this.closeTooltip); // Layer for items added by users this.on('editable:drawing:cancel', function (e) { @@ -1249,19 +1249,53 @@ L.U.Editable = L.Editable.extend({ }, drawingTooltip: function (e) { + if (e.layer instanceof L.Marker && e.type != "editable:drawing:move") { + this.map.ui.tooltip({content: L._('Click to add a marker')}); + } + if (!(e.layer instanceof L.Polyline)) { + // only continue with Polylines and Polygons + return; + } + var content; - if (e.layer instanceof L.Marker) content = L._('Click to add a marker'); - else if (e.layer instanceof L.Polyline) { + var measure; + if (e.layer.editor._drawnLatLngs) { + // when drawing (a Polyline or Polygon) if (!e.layer.editor._drawnLatLngs.length) { - if (e.layer instanceof L.Polygon) content = L._('Click to start drawing a polygon'); - else if (e.layer instanceof L.Polyline) content = L._('Click to start drawing a line'); - } else if (e.layer.editor._drawnLatLngs.length < e.layer.editor.MIN_VERTEX) { - content = L._('Click to continue drawing'); + // when drawing first point + if (e.layer instanceof L.Polygon){ + content = L._('Click to start drawing a polygon'); + } else if (e.layer instanceof L.Polyline) { + content = L._('Click to start drawing a line'); + } } else { - content = L._('Click last point to finish shape'); + var tmpLatLngs = e.layer.editor._drawnLatLngs.slice(); + tmpLatLngs.push(e.latlng); + measure = e.layer.getMeasure(tmpLatLngs); + + if (e.layer.editor._drawnLatLngs.length < e.layer.editor.MIN_VERTEX) { + // when drawing second point + content = L._('Click to continue drawing'); + } else { + // when drawing third point (or more) + content = L._('Click last point to finish shape'); + } + content += ", " + } + } else { + // when moving an existing point + measure = e.layer.getMeasure(); + } + if (measure){ + if (e.layer instanceof L.Polygon){ + content = L._('Polygon area: {measure}', { measure: measure }); + } else if (e.layer instanceof L.Polyline) { + content = L._('Line length: {measure}', { measure: measure }); } } - if (content) this.map.ui.tooltip({content: content}); + if (content) { + this.map.ui.tooltip({content: content}); + } }, closeTooltip: function () { diff --git a/umap/static/umap/js/umap.features.js b/umap/static/umap/js/umap.features.js index f4f51ae2..c872e689 100644 --- a/umap/static/umap/js/umap.features.js +++ b/umap/static/umap/js/umap.features.js @@ -853,8 +853,8 @@ L.U.Polyline = L.Polyline.extend({ return 'polyline'; }, - getMeasure: function () { - var length = L.GeoUtil.lineLength(this.map, this._defaultShape()); + getMeasure: function (shape) { + var length = L.GeoUtil.lineLength(this.map, shape || this._defaultShape()); return L.GeoUtil.readableDistance(length, this.map.measureTools.getMeasureUnit()); }, @@ -1004,8 +1004,8 @@ L.U.Polygon = L.Polygon.extend({ return options.concat(L.U.FeatureMixin.getInteractionOptions()); }, - getMeasure: function () { - var area = L.GeoUtil.geodesicArea(this._defaultShape()); + getMeasure: function (shape) { + var area = L.GeoUtil.geodesicArea(shape || this._defaultShape()); return L.GeoUtil.readableArea(area, this.map.measureTools.getMeasureUnit()); }, diff --git a/umap/static/umap/locale/de.js b/umap/static/umap/locale/de.js index 608c5f1e..e161e354 100644 --- a/umap/static/umap/locale/de.js +++ b/umap/static/umap/locale/de.js @@ -384,4 +384,4 @@ var locale = { "Will be permanently visible in the bottom left corner of the map": "Wird in der unteren linken Ecke der Karte permanent sichtbar sein" }; L.registerLocale("de", locale); -L.setLocale("de"); \ No newline at end of file +L.setLocale("de"); diff --git a/umap/static/umap/locale/de.json b/umap/static/umap/locale/de.json index f3c2a806..578261ca 100644 --- a/umap/static/umap/locale/de.json +++ b/umap/static/umap/locale/de.json @@ -382,4 +382,4 @@ "Permanent credits background": "Dauerhafte Danksagung im Hintergrund", "Select data": "Wähle Daten aus", "Will be permanently visible in the bottom left corner of the map": "Wird in der unteren linken Ecke der Karte permanent sichtbar sein" -} \ No newline at end of file +} diff --git a/umap/static/umap/locale/en.js b/umap/static/umap/locale/en.js index cde374c2..df26261b 100644 --- a/umap/static/umap/locale/en.js +++ b/umap/static/umap/locale/en.js @@ -384,4 +384,4 @@ var locale = { "Will be permanently visible in the bottom left corner of the map": "Will be permanently visible in the bottom left corner of the map" }; L.registerLocale("en", locale); -L.setLocale("en"); \ No newline at end of file +L.setLocale("en"); diff --git a/umap/static/umap/locale/en.json b/umap/static/umap/locale/en.json index d0c032b0..5dc6ce82 100644 --- a/umap/static/umap/locale/en.json +++ b/umap/static/umap/locale/en.json @@ -382,4 +382,4 @@ "Permanent credits background": "Permanent credits background", "Select data": "Select data", "Will be permanently visible in the bottom left corner of the map": "Will be permanently visible in the bottom left corner of the map" -} \ No newline at end of file +} diff --git a/umap/static/umap/locale/en_US.json b/umap/static/umap/locale/en_US.json index 500299e7..d749d865 100644 --- a/umap/static/umap/locale/en_US.json +++ b/umap/static/umap/locale/en_US.json @@ -382,4 +382,4 @@ "Permanent credits background": "Permanent credits background", "Select data": "Select data", "Will be permanently visible in the bottom left corner of the map": "Will be permanently visible in the bottom left corner of the map" -} \ No newline at end of file +} diff --git a/umap/static/umap/locale/ko.js b/umap/static/umap/locale/ko.js index a23abb6f..176d1e7e 100644 --- a/umap/static/umap/locale/ko.js +++ b/umap/static/umap/locale/ko.js @@ -384,4 +384,4 @@ var locale = { "Will be permanently visible in the bottom left corner of the map": "Will be permanently visible in the bottom left corner of the map" }; L.registerLocale("ko", locale); -L.setLocale("ko"); \ No newline at end of file +L.setLocale("ko"); diff --git a/umap/static/umap/locale/ko.json b/umap/static/umap/locale/ko.json index b38ac764..f9045c15 100644 --- a/umap/static/umap/locale/ko.json +++ b/umap/static/umap/locale/ko.json @@ -382,4 +382,4 @@ "Permanent credits background": "Permanent credits background", "Select data": "Select data", "Will be permanently visible in the bottom left corner of the map": "Will be permanently visible in the bottom left corner of the map" -} \ No newline at end of file +}