vstar1411 / leaflet_assignment

0 stars 0 forks source link

Issues regarding calculating scale #4

Open vstar1411 opened 9 months ago

vstar1411 commented 9 months ago

I have used the calculations as given in the PDF but I am not sure if they are correct. I would like you to confirm that calculation for scale_bar value is correct as below

var scale = Math.pow(2, (_this.maxNativeZoom - this._map.getZoom()));
var display_mpp = mpp / scale
var scale_bar_value = display_mpp * scale_bar_length

Since, this calculation would mean the number would decrease as we zoom out. Is this the required functionality?

sanosano commented 9 months ago

@vstar1411

Since, this calculation would mean the number would decrease as we zoom out. Is this the required functionality?

Thank you for pointing that out. The expected behavior is the value should increase when we zoom out, not decrease.

I think the scale should be calculated as follows:

var scale = 1 / Math.pow(2, (_this.maxNativeZoom - this._map.getZoom()));
vstar1411 commented 9 months ago

Thank you @sanosano for clarification. I will update the calculations and submit a pull request once I finish it. Also, one more thing what shall be the unit for distance (Is it in meters, millimetres, etc?)