refactor getMeasure function
This commit is contained in:
parent
3f12b69c25
commit
693b32c0ee
2 changed files with 9 additions and 24 deletions
|
@ -1262,7 +1262,9 @@ L.U.Editable = L.Editable.extend({
|
||||||
content = L._('Click to start drawing a line');
|
content = L._('Click to start drawing a line');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
var readableDistance = e.layer.getMeasure(e.latlng);
|
var tmpLatLngs = this.editor._drawnLatLngs.slice();
|
||||||
|
tmpLatLngs.push(e.latlng);
|
||||||
|
var readableDistance = 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 ({distance})', { distance: readableDistance });
|
content = L._('Click to continue drawing ({distance})', { distance: readableDistance });
|
||||||
|
|
|
@ -853,17 +853,9 @@ L.U.Polyline = L.Polyline.extend({
|
||||||
return 'polyline';
|
return 'polyline';
|
||||||
},
|
},
|
||||||
|
|
||||||
getMeasure: function (extraPoint) {
|
getMeasure: function (shape) {
|
||||||
var polyline;
|
var measure = L.GeoUtil.lineLength(this.map, shape | this._defaultShape());
|
||||||
if (extraPoint){
|
return L.GeoUtil.readableDistance(measure, this.map.measureTools.getMeasureUnit());
|
||||||
var tmpLatLngs = this.editor._drawnLatLngs.slice();
|
|
||||||
tmpLatLngs.push(extraPoint);
|
|
||||||
polyline = tmpLatLngs;
|
|
||||||
} else {
|
|
||||||
polyline = this._defaultShape();
|
|
||||||
}
|
|
||||||
var length = L.GeoUtil.lineLength(this.map, polyline);
|
|
||||||
return L.GeoUtil.readableDistance(length, this.map.measureTools.getMeasureUnit());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getContextMenuEditItems: function (e) {
|
getContextMenuEditItems: function (e) {
|
||||||
|
@ -1012,18 +1004,9 @@ L.U.Polygon = L.Polygon.extend({
|
||||||
return options.concat(L.U.FeatureMixin.getInteractionOptions());
|
return options.concat(L.U.FeatureMixin.getInteractionOptions());
|
||||||
},
|
},
|
||||||
|
|
||||||
getMeasure: function (extraPoint) {
|
getMeasure: function (shape) {
|
||||||
var polygon;
|
var measure = L.GeoUtil.lineLength(this.map, shape | this._defaultShape());
|
||||||
if (extraPoint){
|
return L.GeoUtil.readableArea(measure, this.map.measureTools.getMeasureUnit());
|
||||||
var tmpLatLngs = this.editor._drawnLatLngs.slice();
|
|
||||||
tmpLatLngs.push(extraPoint);
|
|
||||||
polygon = tmpLatLngs;
|
|
||||||
} else {
|
|
||||||
polygon = this._defaultShape();
|
|
||||||
}
|
|
||||||
|
|
||||||
var area = L.GeoUtil.geodesicArea(polygon);
|
|
||||||
return L.GeoUtil.readableArea(area, this.map.measureTools.getMeasureUnit());
|
|
||||||
},
|
},
|
||||||
|
|
||||||
getContextMenuEditItems: function (e) {
|
getContextMenuEditItems: function (e) {
|
||||||
|
|
Loading…
Reference in a new issue