<div dir="ltr"><div>This is the core codes:<br> <br><i><br><br>(function() {<br>    function application() {<br><br>    }<br>    application.prototype = {<br>        init : function() {<br>            this.mmap = new OpenLayers.Map("map");<br>

            this.drawLayer = new OpenLayers.Layer.Vector("drawfeature", {<br>                displayInLayerSwitcher : this.overlayDisplayInLayerSwitcher<br>            });<br>            var measureControls = {<br>

                distance : new OpenLayers.Control.Measure(OpenLayers.Handler.Path, opts),<br>                area : new OpenLayers.Control.Measure(OpenLayers.Handler.Polygon, opts)<br>            };<br>            for ( var key in measureControls) {<br>

                var c = measureControls[key];<br>                c.events.on({<br>                    "measure" : this.handleMeasurements,<br>                    "measurepartial" : this.handleMeasurements,<br>

                    scope : this<br>                });<br>                map.addControl(c);<br>            }<br>            this.measureControls = measureControls;<br><br>            // init the event handler<br>            $(".maptool span").click(function() {<br>

                if ($(this).data("control")) {<br>                    var controlName = $(this).data("control");// distance or<br>                    // area<br>                    var control = that.measureControls[controlName];<br>

                    if (control) {<br>                        control.activate();<br>                    }<br>                }<br>            });<br>        },<br><br>        handleMeasurements : function(event) {<br>            var geometry = event.geometry;<br>

            var units = event.units;<br>            var order = event.order;<br>            var measure = event.measure;<br>            var out = "";<br>            if (order == 1) {<br>                out += "measure: " + measure.toFixed(3) + " " + units;<br>

            } else {<br>                out += "measure: " + measure.toFixed(3) + " " + units + "<sup>2</" + "sup>";<br>            }<br>            if (this.measurePopup) {<br>

                this.mmap.removePopup(this.measurePopup);<br>            } else {<br>                var cps = geometry.getCentroid();<br>                var pos = new OpenLayers.LonLat(cps.x, cps.y);<br>                this.measurePopup = new OpenLayers.Popup("xx", pos, new OpenLayers.Size(80, 20), out, true);<br>

                this.mmap.addPopup(this.measurePopup);<br>            }<br>            if (event.type == "measure") {<br>                // the measurement is completed, then tried to clone the geometry and add it to the darwlayer<br>

                this.drawLayer.addFeatures(geometry.clone());<br></i></div><i>                //deactivate the control, then use can drag-pan the map normally<br></i><div><i>                event.object.deactivate();<br>
            }<br>
        }<br>    }<br>    var app = new application();<br>    window.app = app.app;<br>})();<br>window.onload = function() {<br>    window.app && window.app.init();<br>}</i><br></div></div><div class="gmail_extra">

<br><br><div class="gmail_quote">2013/6/1 Vince Lotito <span dir="ltr"><<a href="mailto:vince@vvl.com" target="_blank">vince@vvl.com</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div dir="auto"><div>Send code sample...<br><br>Sent from my iPad</div><div><div class="h5"><div><br>On Jun 1, 2013, at 9:10 AM, "maven apache" <<a href="mailto:apachemaven0@gmail.com" target="_blank">apachemaven0@gmail.com</a>> wrote:<br>

<br></div><blockquote type="cite"><div>IN  fact, I  have  tried  that, but  it  does  not  work.   I  have  created  a  vector  layer, in  the  measure  event, I  get  the  geometry, clone it, add  it  to  the  layer  using the  addfeature  method, but, it  does  not  worked  as  expected. <br>


<br>reply  by my  HTC phone, sorry  for my  spell. <br><br>在 2013年6月1日星期六,Vince Lotito <<a href="mailto:vince@vvl.com" target="_blank">vince@vvl.com</a>> 写道:<br>><br>> In your measure control tap into the measure event, from there grab the geometry and clone it into a vector layer.... You'll also have to create a text label at the centroid with the actual measurement.<br>


><br>> Vince<br>><br>><br>> Sent from my iPad<br>><br>> On Jun 1, 2013, at 5:15 AM, "maven apache" <<a href="mailto:apachemaven0@gmail.com" target="_blank">apachemaven0@gmail.com</a>> wrote:<br>

><br>
>> Hi:<br>>><br>>> I am using the Measure Control in OpenLayers.<br>>><br>>> And I want to keep the geometry presisit in the map when one measure completed.<br>>><br>>> I know there is a property named "persisit" to make the geomery visible after the measure completed, but once the cancel is called for the control or the deactivate of the handler is called, the geometry will disappeared. This is not what I want.<br>


>><br>>> So I wonder if my requirement is possible?<br>>> _______________________________________________<br>>> Users mailing list<br>>> <a href="mailto:Users@lists.osgeo.org" target="_blank">Users@lists.osgeo.org</a><br>


>> <a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a><br>>
</div></blockquote><blockquote type="cite"><div><span>_______________________________________________</span><br><span>Users mailing list</span><br><span><a href="mailto:Users@lists.osgeo.org" target="_blank">Users@lists.osgeo.org</a></span><br>

<span><a href="http://lists.osgeo.org/mailman/listinfo/openlayers-users" target="_blank">http://lists.osgeo.org/mailman/listinfo/openlayers-users</a></span><br></div></blockquote></div></div></div></blockquote></div><br>
</div>