2

I have created one code to display an image layer on my map using OpenLayers, I am using following code:

tiled = new OpenLayers.Layer.WMS(
                "layername", "domainname/geoserver/workspace/wms",
                {
                    LAYERS: 'layername',
                    STYLES: '',
                    format: 'image/png',
                    tiled: true,
                    transparent: "true",
                    tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
                },
                {
                    buffer: 0,
                    displayOutsideMaxExtent: true,
                    isBaseLayer: false,
                    yx : {'EPSG:900913' : true}
                } 
            );
            map.addLayer(tiled);

My complete code is:

function init() {
    map = new OpenLayers.Map('mapdiv');
    var mapnik = new OpenLayers.Layer.OSM();
    var zoom = 15;
    map.addLayer(mapnik);
    map.setCenter(new OpenLayers.LonLat(151.1522771, -33.7288868).transform(new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")), zoom);
    tiled = new OpenLayers.Layer.WMS("layername", "url", {
            LAYERS : 'layername',
            STYLES : '',
            format : 'image/png',
            tiled : true,
            transparent : "true",
            tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom
        }, {
            buffer : 0,
            displayOutsideMaxExtent : true,
            isBaseLayer : true,
            yx : {
                'EPSG:900913' : true
            }
        });
    map.addLayer(tiled);
}
1
  • Thanks for your reply, I have checked it but after that the zoom in and out function is not working with image . I mean that image layer is not changing as per the zoom level, that is showing static size.
    – user34591
    Aug 19, 2014 at 7:59

1 Answer 1

1

In your code, you are setting isBaseLayer: false; This will make the layer an overlay layer.

If you want it as a base layer, then you just need to set it to true, i.e. isBaseLayer: true

4
  • Thanks for your reply, I have checked it but after that the zoom in and out function is not working with image . I mean that image layer is not changing as per the zoom level, that is showing static size.
    – user34591
    Aug 19, 2014 at 8:00
  • @user34591: Then that means that you have not initialised the map properly. Aug 19, 2014 at 8:08
  • function init() {map = new OpenLayers.Map('mapdiv');var mapnik = new OpenLayers.Layer.OSM();var zoom= 15; map.addLayer(mapnik);map.setCenter(new OpenLayers.LonLat(151.1522771,-33.7288868).transform( new OpenLayers.Projection("EPSG:4326"), new OpenLayers.Projection("EPSG:900913")),zoom); tiled = new OpenLayers.Layer.WMS("layername", "url",{LAYERS: 'layername',STYLES: '',format: 'image/png',tiled: true, transparent: "true",tilesOrigin : map.maxExtent.left + ',' + map.maxExtent.bottom},{buffer: 0,displayOutsideMaxExtent: true,isBaseLayer: true,yx : {'EPSG:900913' : true}} ); map.addLayer(tiled);}
    – user34591
    Aug 19, 2014 at 8:30
  • above is my full code. when I change isBaseLayer: true, as true the image layer is not showing on the map, and its working on false
    – user34591
    Aug 19, 2014 at 8:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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