Take the 2-minute tour ×
Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. It's 100% free, no registration required.

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="http://maps.google.com/maps/api/js?sensor=false&v=3.3" type="text/javascript"></script>
    <script src="http://api.maps.yahoo.com/ajaxymap?v=3.0&appid=abcdefg1234" type="text/javascript"></script>
    <script src="http://openlayers.org/api/OpenLayers.js" 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", 
                                            "http://vmap0.tiles.osgeo.org/wms/vmap0", { 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());
        }
    </script>
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 : jsfiddle.net/4psyk –  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 : jsfiddle.net/8bMHS –  bios Aug 9 '12 at 10:03
add comment

1 Answer 1

up vote 1 down vote accepted

i think this is the problem of projection or resolution.

try to use OSM instead of "http://vmap0.tiles.osgeo.org/wms/vmap0".

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 - vmap0.tiles.osgeo.org/wms/… –  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
show 2 more comments

Your Answer

 
discard

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.