I want to know the distance between two drawn geometries. I look for it and saw in OpenLayers 2 the distanceTo methods but I actually use OpenLayers 4. I know there is haversine method but it's between two points.

Did you know any way to calculate the distance in the last version?

1 Answer 1


You could use JSTS to calculate the distance between your two geometries. There's an example among those of OpenLayers that features JSTS, i.e. it shows how to use buffer but you could try to see from there how you could use the distance operator in JSTS.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.