<div dir="ltr"><br><div class="gmail_extra"><br><br><div class="gmail_quote">On Wed, Jan 16, 2013 at 3:24 PM, Donald Kerr <span dir="ltr"><<a href="mailto:donald.kerr@dkerr.co.uk" target="_blank">donald.kerr@dkerr.co.uk</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div link="blue" vlink="purple" lang="EN-GB"><div><p class=""><span style="color:rgb(31,73,125)">Any takers? Help greatly appreciated.<u></u><u></u></span></p>
<p class=""><span style="color:rgb(31,73,125)"><u></u> <u></u></span></p><div><div style="border-width:1pt medium medium;border-style:solid none none;border-color:rgb(181,196,223) -moz-use-text-color -moz-use-text-color;padding:3pt 0cm 0cm">
<p class=""><b><span style="font-size:10pt;font-family:"Tahoma","sans-serif"" lang="EN-US">From:</span></b><span style="font-size:10pt;font-family:"Tahoma","sans-serif"" lang="EN-US"> <a href="mailto:openlayers-users-bounces@lists.osgeo.org" target="_blank">openlayers-users-bounces@lists.osgeo.org</a> [mailto:<a href="mailto:openlayers-users-bounces@lists.osgeo.org" target="_blank">openlayers-users-bounces@lists.osgeo.org</a>] <b>On Behalf Of </b>Donald Kerr<br>
<b>Sent:</b> 15 January 2013 08:14<br><b>To:</b> <a href="mailto:openlayers-users@lists.osgeo.org" target="_blank">openlayers-users@lists.osgeo.org</a><br><b>Subject:</b> [OpenLayers-Users] Display Radius When Creating Circle with DrawFeature<u></u><u></u></span></p>
</div></div><p class=""><u></u> <u></u></p><p class="">Using the following code,<u></u><u></u></p><p class=""><u></u> <u></u></p><p class="" style="text-autospace:none"><b><span style="font-size:12pt;font-family:"System","sans-serif"">      myLayer = new OpenLayers.Layer.Vector("My Layer");<u></u><u></u></span></b></p>
<p class="" style="text-autospace:none"><b><span style="font-size:12pt;font-family:"System","sans-serif"">      myCtrlCirc = new OpenLayers.Control.DrawFeature(<u></u><u></u></span></b></p><p class="" style="text-autospace:none">
<b><span style="font-size:12pt;font-family:"System","sans-serif"">            myLayer,<u></u><u></u></span></b></p><p class="" style="text-autospace:none"><b><span style="font-size:12pt;font-family:"System","sans-serif"">            OpenLayers.Handler.RegularPolygon,<u></u><u></u></span></b></p>
<p class="" style="text-autospace:none"><b><span style="font-size:12pt;font-family:"System","sans-serif"">            {handlerOptions: {sides: 40}}<u></u><u></u></span></b></p><p class=""><b><span style="font-size:12pt;font-family:"System","sans-serif"">            );</span></b><u></u><u></u></p>
<p class=""><u></u> <u></u></p><p class="">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.<u></u><u></u></p>
<p class=""><u></u> <u></u></p><p class="">Is there a way to display the radius of the circle in a div as it is being created? “<b><span style="font-size:12pt;font-family:"System","sans-serif"">sketchmodified” </span></b>does not seem to get fired and I cannot think of a way to get this to work.<u></u><u></u></p>
<p class=""><u></u> </p></div></div></blockquote><div><br><br></div><div>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:<br>
<br>        if (typeof(displayRadius)==='function') {<br>          displayRadius(new OpenLayers.Geometry.LineString([this.origin, point]));<br>        } <br></div></div><br>displayRadius() is my function that formats the radius to appropriate units and displays it in a div.<br>
<br></div><div class="gmail_extra">HTH,<br>Rich<br></div><div class="gmail_extra"><br>-- <br>Richard Greenwood<br><a href="mailto:richard.greenwood@gmail.com">richard.greenwood@gmail.com</a><br><a href="http://www.greenwoodmap.com">www.greenwoodmap.com</a>
</div></div>