Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draw circle tooltip defaults to feet #690

Open
jdeboer-geoplan opened this issue Feb 14, 2017 · 2 comments
Open

Draw circle tooltip defaults to feet #690

jdeboer-geoplan opened this issue Feb 14, 2017 · 2 comments

Comments

@jdeboer-geoplan
Copy link

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.

@tombrennan06
Copy link

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.

@stevenhorner
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants