Hi Andreas,<div><br></div><div>Sorry to bring this question back from the dead, but u<span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">nless I&#39;m missing something obvious, the sketchmodified event / modify callback aren&#39;t triggered from Handler.RegularPolygon.  This makes some sense, as they&#39;re supposed to take the modified vertex, and in the RegularPolygon, all vertices are modified, but it leaves us without a way of listening for the modification of a RegularPolygon.  </span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px; ">As such, unless anyone can recommend another solution, I think I&#39;m back to passing a customized modifyGeometry in order .  Am I misunderstanding how to listen for this event?  Any other suggestions?</span><br>
</div><div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Thanks,</span></div>
<div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;"><br></span></div><div><span class="Apple-style-span" style="border-collapse: collapse; white-space: pre; -webkit-border-horizontal-spacing: 2px; -webkit-border-vertical-spacing: 2px;">Josh</span></div>
<div><br><div class="gmail_quote">On Wed, Apr 22, 2009 at 4:35 PM, Andreas Hocevar <span dir="ltr">&lt;<a href="mailto:ahocevar@opengeo.org">ahocevar@opengeo.org</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
<div class="im">Josh Rosenthal wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Thanks a lot for the solution using callbacks.  I was wondering if you could suggest how that might be adapted to give the measurements on a draw feature.  It&#39;s much easier than what I was previously doing for measure and drawFeature (passing a customized modifyFeature function in the options, where the new function was the same as the original, but also had the requisite getLength statements - functional, but it seems like this should be far more version dependent than the callback solution).<br>

<br>
When I try to use callbacks-modify on a drawFeature (as below), my modify callback doesn&#39;t seem to get used (the console.log(this) never fires).  I assume this is because measureControls didn&#39;t already use a modify callback, whereas drawFeature does, and as such drawFeature overrides any modify callback I might try to pass in?  Is there any way to append to the normal modify callback?  Am I missing something obvious?<br>

</blockquote>
<br></div>
The best way to achieve this would be to listen for the sketchmodified event of the DrawFeature control. this is what actually gets triggered in the modify callback of the handler that is configured with DrawFeature.<br>

<br>
Regards,<br>
Andreas.<br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div><div class="h5">
<br>
Thanks! <br>
Josh<br>
<br>
broken: uses callbacks - modify:  selectDrawCircle = new OpenLayers.Control.DrawFeature(selectLayerPoly,<br>
                        OpenLayers.Handler.RegularPolygon,{<br>
                            displayClass:&quot;olControlSelectDrawCircle&quot;,<br>
                            element:document.getElementById(&#39;SelectControl_Distance&#39;),<br>
                            unitElement:document.getElementById(&#39;SelectControl_mapUnit&#39;),<br>
                            callbacks:{<br>
                                modify: function (point,feature) {<br>
                    console.log(this);<br>
                                  this.element.value=this.radius.toFixed(2);<br>
                                  this.unitElement.innerHTML=this.map.getUnits();                                                             }<br>
                            },<br>
                            handlerOptions:{<br>
                                sides:40<br>
                                  }<br>
                                });<br>
                            functional: uses slightly customized modifyGeometry function passed in as an option<br>
                 selectDrawCircle = new OpenLayers.Control.DrawFeature(selectLayerPoly,<br>
                        OpenLayers.Handler.RegularPolygon,{<br>
                            displayClass:&quot;olControlSelectDrawCircle&quot;,<br>
                            handlerOptions:{<br>
                                sides:40,<br>
                                element:document.getElementById(&#39;SelectControl_Distance&#39;),<br>
                                unitElement:document.getElementById(&#39;SelectControl_mapUnit&#39;),<br>
                                modifyGeometry: function() {<br>
                                    var angle, dx, dy, point;<br>
                                    var ring = this.feature.geometry.components[0];<br>
                                    // if the number of sides ever changes, create a new geometry<br>
                                    if(ring.components.length != (this.sides + 1)) {<br>
                                        this.createGeometry();<br>
                                        ring = this.feature.geometry.components[0];<br>
                                    }<br>
                                    for(var i=0; i&lt;this.sides; ++i) {<br>
                                        point = ring.components[i];<br>
                                        angle = this.angle + (i * 2 * Math.PI / this.sides);<br>
                                        point.x = this.origin.x + (this.radius * Math.cos(angle));<br>
                                        point.y = this.origin.y + (this.radius * Math.sin(angle));<br>
                                        point.clearBounds();<br>
                                    }<br>
                                    // note, only val b/c this is an input field.<br>
                                  this.element.value=this.radius.toFixed(2);<br>
                                  this.unitElement.innerHTML=this.map.getUnits();<br>
                                }<br>
                         }});<br>
<br>
<br></div></div><div><div></div><div class="h5">
On Wed, Apr 22, 2009 at 8:22 AM, Andreas Hocevar &lt;<a href="mailto:ahocevar@opengeo.org" target="_blank">ahocevar@opengeo.org</a> &lt;mailto:<a href="mailto:ahocevar@opengeo.org" target="_blank">ahocevar@opengeo.org</a>&gt;&gt; wrote:<br>

<br>
    Hi,<br>
<br>
    the solution (if you&#39;re using trunk or 2.8) is quite simple. The snippet<br>
    below replaces the definition of measureControls in the measure example<br>
    (starting around L65)<br>
<br>
               measureControls = {<br>
                   line: new OpenLayers.Control.Measure(<br>
                       OpenLayers.Handler.Path, {<br>
                           callbacks: {<br>
                               modify: function(point, feature) {<br>
                                      measureControls.line.measurePartial(point,<br>
                                           feature.geometry);<br>
                               }<br>
                           },<br>
                           persist: true,<br>
                           handlerOptions: {<br>
                               layerOptions: {styleMap: styleMap}<br>
                           }<br>
                       }<br>
                   ),<br>
                   polygon: new OpenLayers.Control.Measure(<br>
                       OpenLayers.Handler.Polygon, {<br>
                           callbacks: {<br>
                               modify: function(point, feature) {<br>
<br>
    measureControls.polygon.measurePartial(point,<br>
                                           feature.geometry);<br>
                               }<br>
                           },<br>
                           persist: true,<br>
                           handlerOptions: {<br>
                               layerOptions: {styleMap: styleMap}<br>
                           }<br>
                       }<br>
                   )<br>
               };<br>
<br>
    As you can see, the trick is to add a modify callback to the handler,<br>
    calling the control&#39;s measurePartial method.<br>
<br>
    Regards,<br>
    Andreas.<br>
<br>
    pribram pribram wrote:<br>
     &gt; Hi,<br>
     &gt; Is there anything new about measuring + getting distance on<br>
    mousemove?<br>
     &gt;<br>
    <a href="http://n2.nabble.com/Measure-Control---get-distance-on-mouse-move-td2503580.html" target="_blank">http://n2.nabble.com/Measure-Control---get-distance-on-mouse-move-td2503580.html</a><br>
     &gt; If there is a solution, please publish it.<br>
     &gt;<br>
     &gt; Thanks,<br>
     &gt; Pribram<br>
     &gt; _______________________________________________<br>
     &gt; Users mailing list<br></div></div>
     &gt; <a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a> &lt;mailto:<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a>&gt;<div class="im"><br>
     &gt; <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
     &gt;<br>
<br>
<br>
    --<br>
    Andreas Hocevar<br>
    OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
    Expert service straight from the developers.<br>
<br>
    _______________________________________________<br>
    Users mailing list<br></div>
    <a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a> &lt;mailto:<a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a>&gt;<div class="im"><br>
    <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
<br>
<br>
</div></blockquote><div><div></div><div class="h5">
<br>
<br>
-- <br>
Andreas Hocevar<br>
OpenGeo - <a href="http://opengeo.org/" target="_blank">http://opengeo.org/</a><br>
Expert service straight from the developers.<br>
</div></div></blockquote></div><br></div>