Thanks Andreas and Eric for your suggestions, they worked perfectly. I removed 
all the unessecary code and did not define the div inside the creation of my 
map, also added the group to the action buttons and now they work fine, thanks 
again. 




-----Original Message-----
From: Eric Lemoine [mailto:[email protected]] 
Sent: October 04, 2010 1:37 AM
To: Andrew Stewart
Cc: [email protected]
Subject: Re: [Users] Using a Toolbar/Action, control isn't working on my map

On Fri, Oct 1, 2010 at 12:09 AM, Andrew Stewart
<[email protected]> wrote:
> I am trying to use a GeoExt.Action with an Ext.Toolbar to perform actions on
> my map with openlayers controls using the example located here -
> http://www.geoext.org/lib/GeoExt/widgets/Action.html
>
> Unfortunately my buttons are not working, as when I click on the zoom in ./
> zoom out action buttons I created the control is not activated for my map. I
> am thinking this is because of my layout using a mappanel but I just can't
> figure out how to get the controls added to the map properly since I was
> using a working OpenLayers control panel before. Any help greatly
> appreciated, here is my code -


Some comments inline.


>
>
> // -------------------------------------------------- END Define Map Layers
> ---------------------------------
>
>          var map;
>          var startupLat;
>          var startupLon;
>          var lonLat;
>          var startupLevel;
>
>
>          // begin map defintion
>          map = new OpenLayers.Map('map',{controls: [],

As Andreas said do not provide the map with a div when using a
MapPanel. The latter will make a div available to the map.


>          //scales:
> [974000,1867000,3300000,4450000,7075000,14513000,25769000,35654000,58981000,100000000],
>          maxExtent: new OpenLayers.Bounds(-20037508.34, -20037508.34,
> 20037508.34, 20037508.34),
>          maxResolution: 156543.0399,
>          numZoomLevels: 20,
>          units: 'km',
>          projection: new OpenLayers.Projection("EPSG:900913"),
>          displayProjection: new OpenLayers.Projection("EPSG:4326")
>          });    //end of map definition
>
>
>           //Declare 3 Panels for left menu - Themes Panel, Legend Panel and
> Overview Panel
>
>
>             var panel_Map = new GeoExt.MapPanel({
>             collapsed: false,
>             height: 800,
>             renderTo: 'map',
>             map: map,
>             center: lonLat,
>             zoom: startupLevel
>             });
>
>
>             //Define GeoEXT Actions for each Toolbar Button
>
>             var action_home = new GeoExt.Action({
>             text: '&nbsp;&nbsp;Home',
>             cls: 'x-btn-text-icon',
>             icon: '../images/toolbar/home.gif',
>             handler: function(){window.location.reload();},
>             map: map
>         });
>             var action_query = new GeoExt.Action({
>             text: '&nbsp;&nbsp;Queries',
>             cls: 'x-btn-text-icon',
>             icon: '../images/toolbar/query.gif',
>             handler: function()
> {document.getElementById('show-btn').click();},
>             map: map
>         });

You don't need GeoExt.Action for the above actions, just use
Ext.Action. Also, you don't need to provide a reference to the map to
the action.

>             var action_zoomin = new GeoExt.Action({
>             text: '&nbsp;&nbsp;Zoom In',
>             cls: 'x-btn-text-icon',
>             icon: '../images/toolbar/zoomin.gif',
>             control: new OpenLayers.Control.ZoomBox(),
>             map: map
>         });
>             var action_zoomout = new GeoExt.Action({
>             text: '&nbsp;&nbsp;Zoom Out',
>             cls: 'x-btn-text-icon',
>             icon: '../images/toolbar/zoomout.gif',
>             control: new OpenLayers.Control.ZoomBox({title:"Zoom out. Click
> on map or click and drag to zoom out.", out: true}),
>             map: map
>         });

You want to set the "toogleGroup" property for these two actions, see
<http://dev.sencha.com/deploy/dev/docs/?class=Ext.Button>. Look also
at the "allowDepress" property.


Hope it helps,



-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : [email protected]
http://www.camptocamp.com


[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.]




_______________________________________________
Users mailing list
[email protected]
http://www.geoext.org/cgi-bin/mailman/listinfo/users

Reply via email to