[Users] Using a Toolbar/Action, control isn't working on my map
Eric Lemoine
eric.lemoine at camptocamp.com
Mon Oct 4 09:37:11 CEST 2010
On Fri, Oct 1, 2010 at 12:09 AM, Andrew Stewart
<Andrew.Stewart at reddeer.ca> 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: ' 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: ' 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: ' 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: ' 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 : eric.lemoine at camptocamp.com
http://www.camptocamp.com
More information about the Users
mailing list