5

I want to give my user the ability to click on the map and give him a dynamic circle drawing tool which also reads out the radius measurement. That way the user can see how big the circle he creates is.

For example, something like this :

enter image description here

Any idea how I can add such a thing to OpenLayers?

4
  • gis.stackexchange.com/questions/20982/…
    – Roy M J
    Commented Jan 23, 2014 at 7:17
  • 2
    This does not look like a duplicate to me because I can see no mention of the "persist measure of the radius" requirement in the other Question.
    – PolyGeo
    Commented Jan 23, 2014 at 7:42
  • 1
    @PolyGeo is correct - I want to show the radius while the user change the drawn circle size
    – Alophind
    Commented Jan 23, 2014 at 8:42
  • Why not provide a text input for the user to directly specify the radius instead.
    – nagytech
    Commented Jun 27, 2015 at 23:31

1 Answer 1

1

I'd try this way:

  • create a separate layer just for the radii,
  • after each feature creation event on circle layer, construct a LINESTRING with two points: the center of the circle as start point and the easternmost vertex as end point, and calculate its length,
    • add this temporary feature to radii layer and label it with its length.

EDIT: I created a sample jsFiddle for this: http://jsfiddle.net/5TQHK/24/. Beware that if you use EPSG:900913, the calculated length will be too distorted to be useful. Use a local coordinate system or geodesic calculations to get meaningful length.

(I know that real circles don't have vertices, but in most GIS systems they do :) )

2
  • Very nice , Is there a way to show the radius size while the circle being draw ? like in this example : jorix.github.io/OL-DynamicMeasure/examples/measure-dynamic.html
    – Alophind
    Commented Jan 23, 2014 at 13:58
  • Yes, this should be possible as well. To do this you will need to capture the circle geometry at every move. Refer to OpenLayers source code, lib/OpenLayers/Handler/RegularPolygon.js to see how the circle geometry is being constructed and get some idea. Commented Jan 23, 2014 at 21:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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