refactor
This commit is contained in:
parent
afbe7c90d8
commit
f737d81b40
1 changed files with 37 additions and 28 deletions
|
@ -1249,14 +1249,20 @@ L.U.Editable = L.Editable.extend({
|
||||||
},
|
},
|
||||||
|
|
||||||
drawingTooltip: function (e) {
|
drawingTooltip: function (e) {
|
||||||
var content;
|
|
||||||
if (e.layer instanceof L.Marker && e.type != "editable:drawing:move") {
|
if (e.layer instanceof L.Marker && e.type != "editable:drawing:move") {
|
||||||
content = L._('Click to add a marker');
|
this.map.ui.tooltip({content: L._('Click to add a marker')});
|
||||||
} else if (e.layer instanceof L.Polyline) {
|
}
|
||||||
// when drawing a Polyline or Polygon
|
if (!(e.layer instanceof L.Polyline)) {
|
||||||
|
// only continue with Polylines and Polygons
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var content;
|
||||||
|
var measure;
|
||||||
if (e.layer.editor._drawnLatLngs) {
|
if (e.layer.editor._drawnLatLngs) {
|
||||||
// when drawing first point
|
// when drawing (a Polyline or Polygon)
|
||||||
if (!e.layer.editor._drawnLatLngs.length) {
|
if (!e.layer.editor._drawnLatLngs.length) {
|
||||||
|
// when drawing first point
|
||||||
if (e.layer instanceof L.Polygon){
|
if (e.layer instanceof L.Polygon){
|
||||||
content = L._('Click to start drawing a polygon');
|
content = L._('Click to start drawing a polygon');
|
||||||
} else if (e.layer instanceof L.Polyline) {
|
} else if (e.layer instanceof L.Polyline) {
|
||||||
|
@ -1265,7 +1271,8 @@ L.U.Editable = L.Editable.extend({
|
||||||
} else {
|
} else {
|
||||||
var tmpLatLngs = e.layer.editor._drawnLatLngs.slice();
|
var tmpLatLngs = e.layer.editor._drawnLatLngs.slice();
|
||||||
tmpLatLngs.push(e.latlng);
|
tmpLatLngs.push(e.latlng);
|
||||||
var readableDistance = e.layer.getMeasure(tmpLatLngs);
|
measure = e.layer.getMeasure(tmpLatLngs);
|
||||||
|
|
||||||
if (e.layer.editor._drawnLatLngs.length < e.layer.editor.MIN_VERTEX) {
|
if (e.layer.editor._drawnLatLngs.length < e.layer.editor.MIN_VERTEX) {
|
||||||
// when drawing second point
|
// when drawing second point
|
||||||
content = L._('Click to continue drawing');
|
content = L._('Click to continue drawing');
|
||||||
|
@ -1273,15 +1280,17 @@ L.U.Editable = L.Editable.extend({
|
||||||
// when drawing third point (or more)
|
// when drawing third point (or more)
|
||||||
content = L._('Click last point to finish shape');
|
content = L._('Click last point to finish shape');
|
||||||
}
|
}
|
||||||
content += " ("+readableDistance+")";
|
content += ", "
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// when moving an existing point
|
// when moving an existing point
|
||||||
if (e.layer instanceof L.Polygon){
|
measure = e.layer.getMeasure();
|
||||||
content = L._('Polygon area: {measure}', { measure: e.layer.getMeasure() });
|
|
||||||
} else if (e.layer instanceof L.Polyline) {
|
|
||||||
content = L._('Line distance: {measure}', { 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 distance: {measure}', { measure: measure });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (content) {
|
if (content) {
|
||||||
|
|
Loading…
Reference in a new issue