I've been stuck on this for a while now...
What I want to do is wrap a latLng when it crosses the w180 to store the coordinate so I do:
latLng = latLng.wrap()
And that works fine. But later I want to display that original value.
It basically comes down to reverse engineering these operations:
var max = 180;
var min = -180;
var d = max - min;
var lng = latLng.lng === max ? latLng.lng : ((latLng.lng - min) % d + d) % d + min;
var lat = latLng.lat === max ? latLng.lat : ((latLng.lat - min) % d + d) % d + min;
return new L.latLng(lat, lng);
I'm really struggling because of the modulo operations in this equation.
Any help would be greatly appreciated!