Leaflet: Coordinates not accurate when scrolling

Created on 18 Aug 2019  路  4Comments  路  Source: Leaflet/Leaflet

When scrolling on a map the coordinates provided from a popup event reflect a different value from what I expected.

For example if I click near Tokyo Japan I get "35.68296, 139.80151"

Now if I scroll the map to the left until I find Tokyo again I get "35.65925, -220.13155"

Is there a way to force it so it always returns the values within -180 to 180 as expected, or that's something I have to working with maths?

Environment

  • Leaflet version: 1.0.3
  • Browser (with version): Firefox 68.0.1
  • OS/Platform (with version): Windows 7

Most helpful comment

You can use the WrapLatLng function to normalize values.

All 4 comments

You can use the WrapLatLng function to normalize values.

You can use the WrapLatLng function to normalize values.

Thanks gonna give that a try and see how it goes ;)

Closing, @krdyke's answer is correct.

Yes thanks. It worked perfectly ;)

Was this page helpful?
0 / 5 - 0 ratings