[Users] Using a Toolbar/Action, control isn't working on my map
Andreas Hocevar
ahocevar at opengeo.org
Sun Oct 3 10:44:18 CEST 2010
Hi,
it is a common mistake to construct the OpenLayers.Map with a container div.
Instead of
new OpenLayers.Map("map", {...}),
you should construct the map like this:
new OpenLayers.Map({...});
Regards,
Andreas.
On Oct 1, 2010, at 00:09 , Andrew Stewart 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 -
>
>
> // -------------------------------------------------- END Define Map Layers ---------------------------------
>
> var map;
> var startupLat;
> var startupLon;
> var lonLat;
> var startupLevel;
>
>
> // begin map defintion
> map = new OpenLayers.Map('map',{controls: [],
> //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
> });
> 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
> });
>
> //Define toolbar, insert Ext Actions
> var toolbar = new Ext.Toolbar([action_home, action_query, action_zoomin, action_zoomout]);
>
>
> var panel_Bottom = new Ext.Panel({
> collapsed: false,
> items: [toolbar]
> });
>
>
>
> var viewPort1 = new Ext.Viewport({
> layout: "border",
> items: [{
> //Center Region - Map Panel Only
> region: "center",
> items: [panel_Map, panel_Bottom]
> },{
> // West Region - Themes Menu, Legend Menu, Overview Menu
> region: "west",
> xtype: 'panel',
> title: "<center>Themes</center>",
> width: 225,
> split: true,
> collapsible: true,
> collapseMode: 'mini',
> items: [panel_Themes, panel_Legend, panel_Overview]
> }]
> });
>
>
>
>
>
>
> This e-mail is intended for the original recipient(s) only. If you have received it in error, please advise the sender and delete this message.
>
> _______________________________________________
> Users mailing list
> Users at geoext.org
> http://www.geoext.org/cgi-bin/mailman/listinfo/users
--
Andreas Hocevar
OpenGeo - http://opengeo.org/
Expert service straight from the developers.
More information about the Users
mailing list