Closed aliciahogue closed 3 years ago
If you run this code:
import { transformExtent } from 'ol/proj'
console.log(transformExtent([-199.999988540844,-25.00904999895826,199.999988540844,105.051128514163], 'EPSG:4326', 'EPSG:3857'))
you will get exactly same result.
I guess this is because max world bounds for EPSG:4326 is [-180, -90, 180, 90]
.
And here [-20037507.067161832,-558316.5538040891,20037507.067161832,20037508.000000015]
the value in EPSG:3857 20037507.067161832
is equal to 179.999988540844
in EPSG:4326.
So $layer.getSource().getExtent()
shows current valid extent that bound all your features.
Sure it's X axis values can't be out of [-180, 180] or [-20037507.067161832, 20037507.067161832] because there is no features that can have coordinates out of this intervals.
Why you try to set extent longitude not belonging to [-180, 180]
bounds?
Because my layer ( the green outline ) crosses the dateline and if I set the extent to be clipped at the dateline then it is cut off on the edge while the world keeps wrapping. I can try this again, perhaps it was a bug that I was seeing. I understand what you are saying though, and never did the conversion of what openlayers was giving me to see that the output was clipped at 179
Ok. I see 2 possible solutions to workaround longitude out of [-180, 180]:
extent[0] + 360, extent[2] + 360
.I also just noticed that you have extent latitude out of [-90,90] too. I guess solutions above can work for it too.
See attached image for what I mean. Initial extent of layer is set at [-199.999988540844,-25.00904999895826,199.999988540844,105.051128514163]
$layer.getSource().getExtent() returns proper value of [-20037507.067161832,-558316.5538040891,20037507.067161832,20037508.000000015]