<div>Hi Christoph,</div>
<div> </div>
<div>thank you very much for your assistance. I tried the following and it works beautifully. One little problem is the closing of the polygon vertices. Before adding the events listeners, a simple double-click will close the polygon. After adding the events, sometimes I need to double-click twice to close the polygon. Not a big problem though. Thanks again. - Albert Ang</div>
<div> </div>
<div>function report(event) {<br> //OpenLayers.Console.log(event.type, event.feature ? <a href="http://event.feature.id">event.feature.id</a> : event.components);<br> displayWKT(event.feature);<br> }</div>
<div> </div>
<div>aoi.events.on({<br> "beforefeaturemodified": report,<br> "featuremodified": report,<br> "afterfeaturemodified": report,<br> "vertexmodified": report,<br>
"sketchmodified": report,<br> "sketchstarted": report,<br> "sketchcomplete": report </div>
<div>});</div>
<div> </div>
<div>function displayWKT(feature) {<br> var str = wkt.write(feature);<br> // not a good idea in general, just for this demo<br> //str = str.replace(/,/g, ', ');<br> document.getElementById('info').innerHTML = str;<br>
document.aoi.vertex.value = str;<br> <br> var areaAOI = feature.geometry.getGeodesicArea();<br> areaAOI = areaAOI / 1000000;<br> var areaAOIstr = 'Approx. area : ' + areaAOI + ' sq. km';<br> document.getElementById('area').innerHTML = areaAOIstr;</div>
<div> } // end function displayWKT(feature)<br><br></div>
<div class="gmail_quote">On Fri, Feb 19, 2010 at 2:05 AM, Christoph Ratke <span dir="ltr"><<a href="mailto:christoph.ratke@gmx.net" target="_blank">christoph.ratke@gmx.net</a>></span> wrote:<br>
<blockquote style="BORDER-LEFT: #ccc 1px solid; MARGIN: 0px 0px 0px 0.8ex; PADDING-LEFT: 1ex" class="gmail_quote">Hi Mr. Ang,<br><br>you can have a look here:<br><a href="http://dev.openlayers.org/releases/OpenLayers-2.8/examples/modify-feature.html" target="_blank">http://dev.openlayers.org/releases/OpenLayers-2.8/examples/modify-feature.html</a><br>
or here:<br><a href="http://dev.openlayers.org/releases/OpenLayers-2.8/examples/highlight-feature.html" target="_blank">http://dev.openlayers.org/releases/OpenLayers-2.8/examples/highlight-feature.html</a><br><br>Have a good day,<br>
Christoph<br><br><br>Albert Ang schrieb:<br>
<div>
<div></div>
<div>> Dear all,<br>><br>> I need assistance in using the events of DrawFeature and<br>> ModifyFeature. Can anyone provide some examples? I use the DrawFeature<br>> and ModifyFeature as following but need guidance on how to use the<br>
> events of DrawFeature (featureadded) and ModifyFeatures<br>> (featuremodified). Basically I like to use the<br>> feature.geometry.getGeodesicArea() function to calculate area<br>> dynamically when an user draws a polygon or when he modifies the polygon.<br>
><br>> controls = {<br>> dpolygon: new OpenLayers.Control.DrawFeature(aoi,<br>> OpenLayers.Handler.Polygon, drawOptions),<br>> modify: new OpenLayers.Control.ModifyFeature(aoi,<br>
><br>> modifyOptions),<br>> selectVector: new OpenLayers.Control.SelectFeature(aoi,<br>> wktOptions)<br>> }<br>><br>> Thank you in advance.<br>><br>> Albert<br></div></div>> ------------------------------------------------------------------------<br>
><br>> _______________________________________________<br>> Users mailing list<br>> <a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br>> <a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@openlayers.org" target="_blank">Users@openlayers.org</a><br><a href="http://openlayers.org/mailman/listinfo/users" target="_blank">http://openlayers.org/mailman/listinfo/users</a><br>
</blockquote></div><br>