0

I am using OSM basemap in my openlayers application.

    var OSMlayer = new OpenLayers.Layer.OSM( "Simple OSM Map");

    //Creating a Map
    map = new OpenLayers.Map('map', {
        maxExtent : OSMlayer.maxExtent,
        units : OSMlayer.units,
        numZoomLevels : OSMlayer.numZoomLevels,
        projection: new OpenLayers.Projection("EPSG:900913"),
        displayProjection: new OpenLayers.Projection("EPSG:900913"),
    });

    map.addLayers([OSMlayer]);

And I have a WMS service that using Web Mercator coordinates like (12.15, 88.65).

I am adding this WMS service on my map,

    layer = new OpenLayers.Layer.WMS("EcoRegions-Esri WMS", "http://myservicedomain.com/Regions/MapServer/WMSServer", {
            layers : "0",
            format : "image/png32",
            transparent : "true"                    
        }, {
            isBaseLayer : false,
            wrapDateLine : false
        });

    map.addLayers([layer]);

But my WMS tiles are not coming on my map. enter image description here

when I look at chrome network, I see the WMS URL bbox are like this:

   myservicedomain.com/Regions/MapServer/WMSServer?LAYERS=0&
FORMAT=image%2Fpng32&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&
STYLES=&SRS=EPSG%3A900913&BBOX=15028131.255,-5009377.085,20037508.34,0&
WIDTH=256&HEIGHT=256

But BBOX parameter should be like this:

BBOX=15.255,-50.085,20.34,0
  • 2
    Those coordinates are in epsg:4326 not web mercator so the bbox request looks correct. – Ian Turton Jan 14 '16 at 7:55
1

Your map and your WMS layer are projected in Web Mercator (EPSG:900913). Therefore, it is normal that your WMS url bbox are 15028131.255,-5009377.085,20037508.34,0 instead of 15.255,-50.085,20.34,0.

So I cannot see the problem. Is your WMS working properly? What is the result of your WMS queries like:

  myservicedomain.com/Regions/MapServer/WMSServer?LAYERS=0&
FORMAT=image%2Fpng32&TRANSPARENT=true&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&
STYLES=&SRS=EPSG%3A900913&BBOX=15028131.255,-5009377.085,20037508.34,0&
WIDTH=256&HEIGHT=256

Tip: IMHO, It is always better to use the EPSG code EPSG:3857 instead of 900913 for the Web Mercator projection. EPSG:900913 is not an "official" EPSG code.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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