[Users] Context menu on rightclick of tree node

Andrew Stewart Andrew.Stewart at reddeer.ca
Wed Jan 12 18:34:04 CET 2011


 Although I am not familiar with getting a right click context menu to work (yet).. I do have a layer opacity control that works for each layer on my current map. I am just using the GeoExt.LayerOpacitySlider that I add to an Ext Window and when the user clicks a button in my toolbar it pops up and lists all the layers of the current map.

The actual control is declared like -

//Function to add Opacity Slider to Top Window (Opacity Window)
    function addOpacity() {
        var controlOptions = {
        renderTo: Ext.get('opacity_slider'),
        width: 160,
        layer: layer_Base,
                    id: 'slider_opacity'
                };
                slider = new GeoExt.LayerOpacitySlider(controlOptions);
                var slider_layername = slider.layer.name;
            };

I have it initially setup to change Opacity of my base layer. Below is my code basically that uses radio buttons on the ext window and when the user clicks on a different layer, the layer for the control is modified to change the opacity of that layer instead.

  //Function to determine which layer is selected for opacity change
    function toggleSet(rad)
    {
    var name = rad.value;

    switch (name)
    {
    case 'Labels':
    document.getElementById('layers').innerHTML = 'Current Layer: Labels';
    slider.layer = layer_Labels;
    break;

    case 'AOI':
    document.getElementById('layers').innerHTML = 'Current Layer: Areas of Interest';
    slider.layer = layer_AOIs;
    break;

    case 'Trails':
    document.getElementById('layers').innerHTML = 'Current Layer: Trails';
    slider.layer = layer_Trails;
    break;

    case 'Footprints':
    document.getElementById('layers').innerHTML = 'Current Layer: Building Footprints';
    slider.layer = layer_Footprints;
    break;

    case 'Legal':
    document.getElementById('layers').innerHTML = 'Current Layer: Legal Fabric';
    slider.layer = layer_Legal_Fabric;
    break;

    case 'Parcel':
    document.getElementById('layers').innerHTML = 'Current Layer: Parcel Fabric';
    slider.layer = layer_Parcel_Fabric;
    break;

    case 'Base':
    document.getElementById('layers').innerHTML = 'Current Layer: Base Layer';
    slider.layer = layer_Base;
    break;

    case 'Orthos':
    document.getElementById('layers').innerHTML = 'Current Layer: Ortho Images';
    slider.layer = layer_Orthos;
    break;
    }
  }

And here is the actual window with the radio buttons/form to call ToggleSet function

  //Opacity Switcher Window
      var window_SwitchOpacity = new Ext.Window({
          title: 'Change Layer Opacity',
          width: '20%',
          height: '55%',
          closeAction: 'hide',
          closeable: true,
          collapsible: true,
          titleCollapse: true,
          frame: true,
          html: '<div id="opacity_slider"></div><br/><div id="layers">Current Layer: Base</div><form name="form_opacity"><div align="left"><br><input type="radio" name="layers" value="Labels" onclick="toggleSet(this);"> Labels<br><input type="radio" name="layers" value="AOI" onclick="toggleSet(this)"> Areas of Interest<br><input type="radio" name="layers" value="Trails" onclick="toggleSet(this)"> Trails<br><input type="radio" name="layers" value="Footprints" onclick="toggleSet(this)"> Building Footprints<br><input type="radio" name="layers" value="Legal" onclick="toggleSet(this)"> Legal Fabric<br><input type="radio" name="layers" value="Parcel" onclick="toggleSet(this)"> Parcel Fabric<br><input type="radio" name="layers" value="Base" onclick="toggleSet(this)" checked> Base Layer<br><input type="radio" name="layers" value="Orthos" onclick="toggleSet(this)"> Ortho Images</div></form>',
          listeners: {'afterlayout': {fn: addOpacity, single: true}}
          });




Hope this is of some assistance.. I'm sure you can modify this to fit anything else as in doesn't have to be inside an ext window or use radio buttons. Also I'm sure there is a better way/more efficient way to accomplish something like this as this is just a trial control for me and not my final one.... still has much work to go.

________________________________
From: users-bounces at geoext.org [mailto:users-bounces at geoext.org] On Behalf Of Robert Buckley
Sent: January 12, 2011 10:27 AM
To: users at geoext.org
Subject: [Users] Context menu on rightclick of tree node

Hi,

I do need a programmer, but I also would like to learn this stuff. It´s a slow hard struggle!!!

Yours,

Robert



________________________________
[This message has been scanned for security content threats and viruses.]

[The City of Red Deer I.T. Services asks that you please consider the environment before printing this e-mail.]



-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.geoext.org/pipermail/users/attachments/20110112/88751c7e/attachment.htm 


More information about the Users mailing list