0

How to get distance from draw circle feature,?

const radius = feature.getGeometry().getRadius();

The radius can be obtained. (Is this pixel?)

want a meter.

thanks.

Yamada JP
  • 73
  • 1
  • 2
  • 6

1 Answers1

1

The result will be in the units used by the projection you are displaying it in. Typically that will be EPSG:3857 web mercator which uses meters as nominal units, but that is a true scale only at the equator - at 60 degrees north things appear twice the true size, so you should adjust your result for point resolution, and also explicitly specify meters if your projection uses a different unit:

ol.proj.getPointResolution(map.getView().getProjection(), feature.getGeometry().getRadius(), feature.getGeometry().getCenter(), 'm')
Mike
  • 16,042
  • 2
  • 14
  • 30