<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-15">
<META content="MSHTML 6.00.2900.3243" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px">
<DIV>Hi George</DIV>
<DIV> </DIV>
<DIV>Here is how I specify the controls:</DIV>
<DIV> </DIV>
<DIV>//Select, Draw and Modify controls - these are specific to the layer<BR> controls = {<BR> select: new OpenLayers.Control.SelectFeature(crops, {callbacks: {'over':feature_info}}),<BR> dpolygon: new OpenLayers.Control.DrawFeature(crops,OpenLayers.Handler.Polygon),<BR> modify: new OpenLayers.Control.ModifyFeature(crops),<BR> delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {crops.destroyFeatures([feature])}})<BR> //delf: new OpenLayers.Control.SelectFeature(crops, {onSelect: function(feature) {feature.geometry.destroy();crops.eraseFeatures([feature])}})<BR> };<BR> for(var key in controls) {<BR> map.addControl(controls[key]);<BR> }</DIV>
<DIV> </DIV>
<DIV>Then I have a function that responds to radio buttons in a div outside the map that sets the mode and activates or deactivates the controls:</DIV>
<DIV> </DIV>
<DIV> function toggleControl(element) {<BR> mode = element.value;<BR> OpenLayers.Util.getElement('comments').innerHTML = "Mode:" + mode;<BR> if ((mode == "select") || (mode == "modify")){<BR> crop_style.strokeColor = "#0000ff";<BR> }<BR> else {<BR> crop_style.strokeColor = "#ff0000";<BR> }<BR> for(key in controls) {<BR> var control = controls[key];<BR> if(element.value == key && element.checked) {<BR> control.activate();<BR> } else {<BR> control.deactivate();<BR> }<BR> }<BR> crops.onFeatureInsert = function(feature) {<BR> feature.attributes.prop0 = 'new'; //This should be modified to get actual ID<BR> alert("New crop area inserted");<BR> }<BR> }</DIV>
<DIV><BR>Hope that helps.</DIV>
<DIV> </DIV>
<DIV>Robert S<BR>>>> Geo-rge <George@muammar.net> 28/05/2009 8:41 a.m. >>><BR><BR>Dear List,<BR><BR>I am having trouble trying to capture events when the ModifyFeature control<BR>is activated and deactivated.<BR><BR>I define my control as such:<BR><BR> modify = new<BR>OpenLayers.Control.ModifyFeature(lyrPlanning,{'displayClass':<BR>'olControlModifyFeature',<BR> 'mode': OpenLayers.Control.ModifyFeature.RESHAPE |<BR>OpenLayers.Control.ModifyFeature.DRAG |<BR>OpenLayers.Control.ModifyFeature.ROTATE});<BR><BR>I try to register the event like this:<BR> modify.events.register('deactivate',modify,modify_deactivated);<BR><BR>this last line causes a syntax error!<BR><BR>I had already defined<BR>function modify_deactivated() {alert('!');}"<BR><BR>I have that feeling that I am doing something so silly I will never get it.<BR>Appreciate any help<BR><BR>George Mu'ammar<BR>-- <BR>View this message in context: <A href="http://n2.nabble.com/Control">http://n2.nabble.com/Control</A>-activate-and-deactivate-events-tp2983592p2983592.html<BR>Sent from the OpenLayers Users mailing list archive at Nabble.com.<BR><BR>_______________________________________________<BR>Users mailing list<BR>Users@openlayers.org<BR><A href="http://openlayers.org/mailman/listinfo/users">http://openlayers.org/mailman/listinfo/users</A><BR><BR></DIV><br><br><table bgcolor=white style="color:black"><tr><td><br>------------------------------------------------------------------<br>
The contents of this email are confidential to AsureQuality. If you have received this communication in error please notify the sender immediately and delete the message and any attachments. The opinions expressed in this email are not necessarily those of AsureQuality. This message has been scanned for known viruses before delivery. AsureQuality supports the Unsolicited Electronic Messages Act 2007. If you do not wish to receive similar communications in future, please notify the sender of this message.<br>
------------------------------------------------------------------</td></tr></table><br><br>
<P align=center><FONT style="BACKGROUND-COLOR: #ffffff">This message has been scanned for malware by SurfControl plc. </FONT><A href="http://www.surfcontrol.com/"><FONT style="BACKGROUND-COLOR: #ffffff" color=#000000>www.surfcontrol.com</FONT></A></P>
</body></HTML>