i will use a OpenLayers example in EPSG:4326, but the value of longitude is not wrapping on 180/-180 longitude.
How can i fix it?
My first problem is, i can't pick the values of latitude and longitude in a value for a if calculation.
if (lon > 180) {
lon = (((lon / 180) - Math.floor(lon / 180)) * 180);
}
if (lon < -180) {
lon = (((((lon * -1) / 180) - Math.floor((lon * -1) / 180)) * (180 * -1) + 180));
}
How do I extract the coordinates into a variable?
Or is there another solution?
The OpenLayers Example:
https://openlayers.org/en/latest/examples/mouse-position.html
The OL example in a JSFiddle:
https://jsfiddle.net/eqjjp4u8/
Best Answer
Try this as your
ol.control.MousePosition
:Check out your modified JSFiddle.
Update: Now using
modifiedCoordinate
to limit the number of digits!