Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

If i use a single wmslayer as map baselayer it loads the map, but adding different layers like (google,yahoo) to map it won't works. Can anyone tell me how to overcome this.. thanks in advance.. please check this:

    <script src="" type="text/javascript"></script>
    <script src="" type="text/javascript"></script>
    <script src="" type="text/javascript"></script>

    <script type="text/javascript">
        var map;

        function init() {
           map = new OpenLayers.Map('map');

           var googleLayer = new OpenLayers.Layer.Google("Google", { 'sphericalMercator': true,
                                'maxExtent': new OpenLayers.Bounds(-20037508.34, -20037508.34, 20037508.34, 20037508.34)});
           var wmsLayer = new OpenLayers.Layer.WMS("OpenLayers WMS", 
                                            "", { layers: 'basic' });
           var yahooLayer = new OpenLayers.Layer.Yahoo("Yahoo");

           map.addLayers([googleLayer, wmsLayer, yahooLayer]);

           map.setCenter(new OpenLayers.LonLat(75.5, 8.5), 5);
           map.addControl(new OpenLayers.Control.LayerSwitcher());
           map.addControl(new OpenLayers.Control.MousePosition());
share|improve this question
can you clarify "doesn't work"? – iant Aug 9 '12 at 9:56
it doesn't load the map. I've fiddle the code please check : – bios Aug 9 '12 at 10:01
I've found that it is because of the yahoo layer, and i removed it. But there is other problems. first one: map center in google and wms layers are different. second: longitude and latitude values of google layer is higher. how to solve this please help me to learn. I've fiddle my code here please check : – bios Aug 9 '12 at 10:03
up vote 1 down vote accepted

i think this is the problem of projection or resolution.

try to use OSM instead of "".

map.addLayer(new OpenLayers.Layer.OSM());

i hope it helps you...

share|improve this answer
in fact that server does handle 900913 so it should work -… – iant Aug 9 '12 at 9:57
try to use this example codes instead of yours. – Aragon Aug 9 '12 at 9:59
That example is only for google layer, but i'm trying to combine two or more different layers – bios Aug 9 '12 at 10:07
@bios add this line map.addLayer(new OpenLayers.Layer.OSM()); to google map example which i have given above. i have tested, it was working... – Aragon Aug 9 '12 at 10:24
@Aragon :can you please update that fiddle with that code, and please post that link – bios Aug 9 '12 at 10:30

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.