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

Excessive approximation of tooltip values (map marker) #200

Closed
hupe13 opened this issue May 11, 2022 · 4 comments
Closed

Excessive approximation of tooltip values (map marker) #200

hupe13 opened this issue May 11, 2022 · 4 comments

Comments

@hupe13
Copy link
Contributor

hupe13 commented May 11, 2022

Hi Raruto,

during my tests, I noticed the accuracy of the tooltip and marker information. Most of the time, the marker is rounded to whole numbers, altitude and distance have options opts.decimalsX and opts.decimalsY. Isn't it better to use the same precision for the marker and tooltip? Or even better you can make the accuracy dependent on the size of value. Is this useful and possible?

grafik grafik grafik grafik

Thank you very much.

@Raruto
Copy link
Owner

Raruto commented May 12, 2022

As I remember lately I added this option as well (mainly in use within the various handlers):

// Limit floating point precision.
if (!isNaN(props.decimals)) {
curr[attr] = _.round(curr[attr], props.decimals);
}


Regarding the following options:

decimalsX: 2,
decimalsY: 0,

they are a legacy of MrMufflon/Leaflet.Elevation library. Honestly, I don't know how much they are in use today and personally I've never even felt the need to use them.


Isn't it better to use the same precision for the marker and tooltip?

If I'm not mistaken in the beginning it was like this, but in my opinion the information showed inside the map marker was more difficult to read, also because the tooltip moves in multiple dimensions while hovering. For example, the acceleration value showed too many useless changes in the decimals part that could distract the user too much from the value contained inside the integer part (which should be the most relevant part).


Or even better you can make the accuracy dependent on the size of value. Is this useful and possible?

Possible, but I don't think we can make it a general rule that applies to everyone, anyway, let me know if you think you have a pretty nifty solution.

Have a nice day,
Raruto

@hupe13
Copy link
Contributor Author

hupe13 commented May 12, 2022

I think the best is when the accuracy is dependent on the size. What do I care about the decimal places when the speed is 500 km/h? But it's not really true when the displayed value on the marker is always 0 when in the tooltip it's in the range from 0 to 0.5 (e.g.)
I will think about it.

@Raruto Raruto changed the title accuracy, decimal places Excessive approximation of tooltip values (map marker) May 12, 2022
@hupe13
Copy link
Contributor Author

hupe13 commented Sep 24, 2022

#210 (comment)
I will use

parseFloat((x).toPrecision(n))

because of

// note that exponential notation might be returned in some circumstances
console.log((1234.5).toPrecision(2)) // logs '1.2e+3'

(see here)

@hupe13
Copy link
Contributor Author

hupe13 commented Dec 18, 2022

I'm closing this, I solved it with your example code.

Thank you very much.

@hupe13 hupe13 closed this as completed Dec 18, 2022
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

2 participants