You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Seems to be an issue between the options in Draw.Circle.js and what's expected in GeometryUtil.js readableDistance
The options in Draw.Circle say
metric: true, // Whether to use the metric measurement system or imperial
feet: true, // When not metric, use feet instead of yards for display
nautic: false // When not metric, not feet use nautic mile for display
But this isn't how readableDistance works
if (typeof isMetric == "string") {
units = isMetric;
} else {
if (isFeet) {
units = 'feet';
} else if (isNauticalMile) {
units = 'nauticalMile';
} else if (isMetric) {
units = 'metric';
} else {
units = 'yards';
}
}
So if isMetric is true in readableDistance then if actually uses feet.
I can get round this by having an options with a metric value of 'metric' rather than true but I'm sure that one or the other of these is wrong.
The text was updated successfully, but these errors were encountered:
Agree - you can also work around it by setting feet:false in the options for each feature type, but that's just a kludge.
The if statement should be rearranged so that feet is below metric:
if (typeof isMetric == "string") {
units = isMetric;
} else {
if (isNauticalMile) {
units = 'nauticalMile';
} else if (isMetric) {
units = 'metric'; } else if (isFeet) {
units = 'feet';
} else {
units = 'yards';
}
}
I've never used git before, but maybe I can see if I can create a pull request.
This doesn't just affect Draw.Circle it's also the same for Polyline. Just lost an hour thinking the options I was passing in were incorrect.
passing the options with the added feet: false fixed this:
metric: false,
feet: false
This then shows me the length of my Polyline in miles and yards, documentation appears to show that you should not need to add feet and in my case using imperial surely it should have shown in yards anyway.
If I did not add the feet: false it would always show the length in feet whether I set metric to false or true.
This is visible in the demo http://leaflet.github.io/Leaflet.draw/docs/examples/full.html
Seems to be an issue between the options in Draw.Circle.js and what's expected in GeometryUtil.js readableDistance
The options in Draw.Circle say
metric: true, // Whether to use the metric measurement system or imperial
feet: true, // When not metric, use feet instead of yards for display
nautic: false // When not metric, not feet use nautic mile for display
But this isn't how readableDistance works
if (typeof isMetric == "string") {
units = isMetric;
} else {
if (isFeet) {
units = 'feet';
} else if (isNauticalMile) {
units = 'nauticalMile';
} else if (isMetric) {
units = 'metric';
} else {
units = 'yards';
}
}
So if isMetric is true in readableDistance then if actually uses feet.
I can get round this by having an options with a metric value of 'metric' rather than true but I'm sure that one or the other of these is wrong.
The text was updated successfully, but these errors were encountered: