[OpenLayers-Users] Map Base layers and controls

ilias kanellos ilias.kanellos at gmail.com
Sun Aug 8 19:02:36 EDT 2010


Hello developers,

I am trying to do a basic setup of a map with some base layers and a few
navigation controls. I've started by trying out only a WMS and a Virtual
Earth layer. I also added a layer switcher control, and I tried setting the
basic map navigation keys. It all seems to work for the WMS layer, but on
the Virtual earth layer it seems that only zooming is possible and it won't
pan. What's more, it seems that the Virtual earth layer isn't "following"
any panning that is done when WMS is selected. Instead everytime I change to
the Virtual Earth layer the map centers on a fixed position with only the
zoom level changed. Can anyone point out where the problem might be?
My code looks like this:


                    //Creating a new map object
                    var newMap = new OpenLayers.Map(divId,
                                    {
                                     controls: [],
                                     projection: "EPSG:4326"
                                    }
                                );

                    //Creating wms url table
                    var urlArray = ["
http://t1.labs.metacarta.com/wms-c/Basic.py",
                                    "
http://t2.labs.metacarta.com/wms-c/Basic.py",
                                    "
http://t3.labs.metacarta.com/wms-c/Basic.py",
                                    "
http://t4.labs.metacarta.com/wms-c/Basic.py"];

                    //Creating a WMS layer

                    var wms = new OpenLayers.Layer.WMS("WMS", urlArray,
                                    {
                                     layers: 'basic',
                                     displayOutsideMaxExtent: true
                                    }
                                );

                      //Creating a virtual earth layer
                      var VEhybrid = new
OpenLayers.Layer.VirtualEarth("Virtual Earth",
                                    {
                                     type: VEMapStyle.Hybrid,
                                     sphericalMercator: true
                                    }
                                );

                    //Setting layers and starting zoom
                    newMap.addLayers([wms, VEhybrid]);
                    newMap.zoomTo(1);


                    //Adding map controls
                    newMap.addControl(new
OpenLayers.Control.LayerSwitcher());
                    newMap.addControl(new
OpenLayers.Control.PanZoomBar({zoomWorldIcon:true}));
                    newMap.addControl(new OpenLayers.Control.Navigation
                                           (
                                                {
                                                    zoomBoxEnabled: true,
                                                    zoomWheelEnabled: true,
                                                    zoomBoxKeyMask:
OpenLayers.Handler.MOD_SHIFT,
                                                    autoActivate: true

                                                }
                                           )
                                      );
                    newMap.addControl(new
OpenLayers.Control.MousePosition());

------------------------------------------------------------------------------------------------------------------------------------

I'm sorry if this topic is novice, but i'm a newbie to openlayers and i
couldn't find any answer to this.
Also, it seemed to me that the open layers example page had a similar
problem when using WMS and bing maps together.
Thank you for your help
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/openlayers-users/attachments/20100809/4f1127a5/attachment.html


More information about the Users mailing list