1

I am using Openalayer 2.12, extjs 4.1 and geoextjs 2. I have created toolbar using geoext js Using link. Now in this link you can find select feature. but i have modified the code as

action = Ext.create('GeoExt.Action', {
    tooltip: "select",
    icon: 'Images/sel.png',
    control: new OpenLayers.Control.SelectFeature(building),
    map: map,
    // button options
    toggleGroup: "tools",
    enableToggle: true,
    group: "tools",
    handler: function() {
                    //alert("Select the feature");
                    ed=null;
                    sm=1;
                }       

            });

actions["select"] = action;
toolbarItems.push(Ext.create('Ext.button.Button', action));

Now this code select the layer building now i want to unselect this selected feature on click of other tool in toolbar and code i have

action = Ext.create('GeoExt.Action', {
        tooltip: "Unselect",
        icon: 'Images/unsel.png',
        handler: function() {

                    }       

                }); 
actions["unselect"] = action;
toolbarItems.push(Ext.create('Ext.button.Button', action));

Can any one please help me to unselect the feature in this example

1

There's an unselectAll() function in the SelectFeature Control. Here's an example (untested):

action = Ext.create('GeoExt.Action', {
    tooltip: "Unselect All",
    icon: 'Images/unsel.png',
    handler: function() {
        selectControls = map.getControlsByClass("OpenLayers.Control.SelectFeature")
        for(var i=0; i<selectControls.length; i++) {
            selectControls[i].unselectAll();
        }
    }       
}); 
actions["unselect"] = action;
toolbarItems.push(Ext.create('Ext.button.Button', action));

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.