[OpenLayers-Users] Display Radius When Creating Circle with DrawFeature

Donald Kerr donald.kerr at dkerr.co.uk
Tue Jan 22 06:41:32 PST 2013


Rich,

 

That is exactly what I am looking for. I am also now using getLength() to
give me the length of the resultant linestring in metres which is my map
coordinate system. Perfect.

 

Many thanks. Much appreciated.

 

Regards,

 

Donald

 

 

From: Richard Greenwood [mailto:richard.greenwood at gmail.com] 

Sent: 22 January 2013 02:02

To: Donald Kerr

Cc: OpenLayers

Subject: Re: [OpenLayers-Users] Display Radius When Creating Circle with
DrawFeature

 

 

 

On Wed, Jan 16, 2013 at 3:24 PM, Donald Kerr <donald.kerr at dkerr.co.uk>
wrote:

Any takers? Help greatly appreciated.

 

From: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Donald Kerr

Sent: 15 January 2013 08:14

To: openlayers-users at lists.osgeo.org

Subject: [OpenLayers-Users] Display Radius When Creating Circle with
DrawFeature

 

Using the following code,

 

      myLayer = new OpenLayers.Layer.Vector("My Layer");

      myCtrlCirc = new OpenLayers.Control.DrawFeature(

            myLayer,

            OpenLayers.Handler.RegularPolygon,

            {handlerOptions: {sides: 40}}

            );

 

I am creating a circle (40 sided polygon) by mousing down on the map,
dragging the mousing up. After mouseup, the polygon is added to the layer as
a vector feature. This allows me to see the size of the circle as I am
drawing it.

 

Is there a way to display the radius of the circle in a div as it is being
created? "sketchmodified" does not seem to get fired and I cannot think of a
way to get this to work.

 

 

I ended up modifying the the OpenLayers RegularPolygon.js to do this,
although I imagine that a better JS programmers than myself might be able to
extend the method or do something more elegant. In the move: function just
before this.modifyGeometry() I added this:

 

        if (typeof(displayRadius)==='function') {

          displayRadius(new OpenLayers.Geometry.LineString([this.origin,
point]));

        } 

 

displayRadius() is my function that formats the radius to appropriate units
and displays it in a div.

HTH,

Rich

 

-- 

Richard Greenwood

richard.greenwood at gmail.com

www.greenwoodmap.com 

No virus found in this message.

Checked by AVG - www.avg.com

Version: 2013.0.2890 / Virus Database: 2639/6048 - Release Date: 01/21/13

 

 

From: Richard Greenwood [mailto:richard.greenwood at gmail.com] 
Sent: 22 January 2013 02:02
To: Donald Kerr
Cc: OpenLayers
Subject: Re: [OpenLayers-Users] Display Radius When Creating Circle with
DrawFeature

 

 

 

On Wed, Jan 16, 2013 at 3:24 PM, Donald Kerr <donald.kerr at dkerr.co.uk>
wrote:

Any takers? Help greatly appreciated.

 

From: openlayers-users-bounces at lists.osgeo.org
[mailto:openlayers-users-bounces at lists.osgeo.org] On Behalf Of Donald Kerr
Sent: 15 January 2013 08:14
To: openlayers-users at lists.osgeo.org
Subject: [OpenLayers-Users] Display Radius When Creating Circle with
DrawFeature

 

Using the following code,

 

      myLayer = new OpenLayers.Layer.Vector("My Layer");

      myCtrlCirc = new OpenLayers.Control.DrawFeature(

            myLayer,

            OpenLayers.Handler.RegularPolygon,

            {handlerOptions: {sides: 40}}

            );

 

I am creating a circle (40 sided polygon) by mousing down on the map,
dragging the mousing up. After mouseup, the polygon is added to the layer as
a vector feature. This allows me to see the size of the circle as I am
drawing it.

 

Is there a way to display the radius of the circle in a div as it is being
created? "sketchmodified" does not seem to get fired and I cannot think of a
way to get this to work.

 

 

I ended up modifying the the OpenLayers RegularPolygon.js to do this,
although I imagine that a better JS programmers than myself might be able to
extend the method or do something more elegant. In the move: function just
before this.modifyGeometry() I added this:

        if (typeof(displayRadius)==='function') {
          displayRadius(new OpenLayers.Geometry.LineString([this.origin,
point]));
        } 


displayRadius() is my function that formats the radius to appropriate units
and displays it in a div.

HTH,
Rich


-- 
Richard Greenwood
richard.greenwood at gmail.com
www.greenwoodmap.com 

No virus found in this message.
Checked by AVG - www.avg.com
Version: 2013.0.2890 / Virus Database: 2639/6048 - Release Date: 01/21/13

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/openlayers-users/attachments/20130122/742e2538/attachment-0001.html>


More information about the Users mailing list