[OpenLayers-Users] Modify object other then from muse click

Alexandre Dube adube at mapgears.com
Mon Feb 8 10:33:15 EST 2010


Poul,

you already keep track of your feature when selecting it with your 
SelectFeature control :

selectedfeature = feature;

so you don't need to make any loop (you should also deactivate the 
SelectFeature control too and do the opposite when your checkbox is 
unchecked):


if (document.getElementById('checkbox_editable').checked==true)
			{	
				alert("Watch out!!!");
				drawControls["chooseobject"].unselect(selectedfeature);
				drawControls["chooseobject"].deactivate();

                                drawControls["modify_wfs_layer"].selectControl.select(selectedfeature);
				drawControls["modify_wfs_layer"].activate();				
				....
			}
else {
    // do the opposite...
}

Regards,

Alexandre


paweluz wrote:
> Hi!
>
> Thanks for your help but unfortunately it does not work. Here is my code:
>
> My controlls
>
>             drawControls = {
>                 chooseobject: new OpenLayers.Control.SelectFeature(
> 					zielona_wfs,
> 					{
> 						onSelect: onFeatureSelect	
> 					}
> 				),
> 				modify_wfs_layer: new OpenLayers.Control.ModifyFeature(zielona_wfs)
>          			....	
>                                };
>
> Getting the feature
>
>         function onFeatureSelect(feature) {
>                         ....
> 			selectedfeature = feature;
>                         ...
>                         }
>
> Checkbox Onclick method
>
>                 function edit_object()
> 		{
> 			if (document.getElementById('checkbox_editable').checked==true)
> 			{	
>
> 				.....				
> 				for(var i=0; i<selectedfeature.length; i++) 
> 				{
> 					alert("Watch out!!!");
> 					drawControls["chooseobject"].unselect(selectedfeature[i]);
> 				
> drawControls["modify_wfs_layer"].selectControl.select(selectedfeature[i]);
> 				}			
> 				drawControls["modify_wfs_layer"].activate();				
> 				....
> 			}
>                }
>
> The alert does not appear even once! I checked in firebug that
> selectedfeature is not empty. This is a screen from firebug
>
> http://i47.tinypic.com/2dwarzr.jpg
>
> I am not sure about the length property?? What do you thing. Maybe I made so
> mistake?? 
>
> Cheers,
> Poul
>
>   


-- 
Alexandre Dubé
Mapgears
www.mapgears.com




More information about the Users mailing list