I want to transform the coordinates for an entire feature in openlayers. I have had success using ol.proj.transform to transform a single coordinate to a different projection, but is there any function that you can feed an entire feature, and all the coordinates within that feature will be transformed to the desired projection? Thanks in advance for any help you can provide!
I think you need ol.geom.Geometry.transform
If you have your feature, then you can do:
src = 'EPSG:3857'
dest = 'EPSG:4326'
feature.getGeometry().transform(src, dest)
The docs are here:
http://openlayers.org/en/latest/apidoc/module-ol_geom_Geometry-Geometry.html#transform
If you do not want the geometry modified in place, first clone()
it and then use this function on the clone.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With