Preciseness Of Leaflet Measurement Conversions
Solution 1:
If I understand correctly, you first convert your LatLng to a pixel position on your current map view (zoom 9, whatever view port dimensions).
Then you convert that pixel position back to a LatLng, and notice a discrepancy with your original LatLng.
It seems to me that you simply observe the effect of pixel rounding: map.latLngToLayerPoint
will give you integer pixel coordinates, hence your precision will be no better than what a pixel covers in terms of actual distance.
At zoom 9 and New York latitude (40.687), the scale is about 20km for 86px, so about 230m per pixel.
The distance between the 2 LatLng coordinates you report is about 103m. Therefore it is well within a single pixel.
Live demo: https://jsfiddle.net/3v7hd2vx/149/ (results are printed in the console)
You can play with map zoom to see the precision improving, as each pixel will cover a smaller distance (area actually).
Post a Comment for "Preciseness Of Leaflet Measurement Conversions"