Possible Duplicate:
Unproject Radius with Openlayers with CRS:84 Projection

I allow a user to draw a circle in Openlayers.

I created an alert to show the radius of the circle.

I now need to convert the radius to kilometers.

For example 0.001788057579325097 (How many kilometers is this)

How do I change this to kilometers? I think its just the decimals that is the problem.

      // The Drag function is now made and called
         // Add Drag
     drag = new OpenLayers.Control.DragFeature(polygonLayer, {
     autoActivate: true,
     onComplete: displayRadius

 function displayRadius(circle) {
     var area = circle.geometry.getArea();
     var radius = 0.565352 * Math.sqrt(area);

marked as duplicate by whuber Mar 19 '12 at 20:51

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • What projection do you use? – drnextgis Feb 29 '12 at 11:29
  • @drnextgis EPSG:4326 for my one map and CRS:84 for my other map – Blake Loizides Feb 29 '12 at 12:02
  • Can you show some code? I'll tell you what that number that is if you show me the code that is producing it. – CaptDragon Feb 29 '12 at 13:48
  • 2
    A figure consisting of points at a constant number of degrees from a center is not a circle! The length of a decimal degree changes with direction (and is usually noticeably longer in the north-south direction than in the east-west direction). A value like 0.001788... decimal degrees will range from 200 meters down to 200 * cos(latitude) meters. The solution is to use an appropriate projected coordinate system for drawing the circle so that your user gets close to a true circle rather than a (grievously) distorted one. – whuber Feb 29 '12 at 16:54
  • 1
    I'm a chronic liar. getArea() will return whatever map units you have chosen. In my case it's meters because i have meters as my map units which i have specified in my constructor like this: ...maxResolution: 156543, units: 'm', projection: "EPSG:41001"... – CaptDragon Feb 29 '12 at 20:43

You can create a path geometry from center to some point of your cercle and get the distance of the path (similar to what measure control does).

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