I develop HTML pages by using OpenLayers, which points to a local GeoServer WMS service. On displaying a layer, it stops at its available max zoom level, but it is still too small to manipulate (a polygon of 10 meter square). Is there a way to increase the zoom level? Where should I do the workaround -- on the OpenLayers or the layer setting in GeoServer? This is my OpenLayers code:

    var xwms = new OpenLayers.Layer.WMS( "Central Java",
        layers: 'basemap',
        styles: 'tlx_map_land',
        bgcolor: '0xBED0DE'
    } );
    var map = new OpenLayers.Map({
       div: "map",
       layers: [xwms],
       controls: [
           new OpenLayers.Control.Navigation({
               dragPanOptions: {
                   enableKinetic: true
           new OpenLayers.Control.PanZoom(),
           new OpenLayers.Control.Attribution()
       center: [110.248191,-7.477177],
       zoom: 13

         ============================ solved ===============================

Finally, I decided to utilise Klokantech's tool to generate custom bounding box(es), set it into both layer publishing in GeoServer and OpenLayers map options. To everyone who participate, thanks for your time and attention.

  • 1
    Welcome to GIS.SE. Can you post the relevant section of your openlayers code? Also, can you tell us what the subject of "its available max zoom level" is (i.e. does "its" mean the openlayers limit or the geoserver limit)? What have you already tried? What happened? Please consider editing your question (just click edit above) to add this important information.
    – BradHards
    Jan 13, 2014 at 5:39
  • Can you add the layer settimgs in Geoserver too? I don't see much possibilities on Openlayer's side.
    – AndreJ
    Jan 13, 2014 at 6:25
  • Where are you setting the projection for the map? Jan 13, 2014 at 6:30
  • I use the EPSG:4326 and bounds to 110.214080810547, -7.51811838150024, 110.215797424316, 0.0374035723507404 (I took it from 'compute from data' in GeoServer.
    – Andy
    Jan 13, 2014 at 6:50
  • @AndreJoost : Layer setting is -- PostGIS data store, and everything is still GeoServer's default value, except for the Native Bounding Box and Lat/Lon Bounding Box, which I generate automatically.
    – Andy
    Jan 13, 2014 at 6:55

2 Answers 2


Have you tried adding numZoomlevels in the openlayers call??

from the doc:


{Integer} Number of zoom levels for the map.  Defaults to 16.  Set a different value in the map options if needed.

This is how I added it to display OSM-like tiles:

        var map; 
        function init() {

            map = new OpenLayers.Map ("map", {
            controls:[ new OpenLayers.Control.Zoomlevel(),
                       new OpenLayers.Control.Navigation(),
                       new OpenLayers.Control.PanZoomBar(),
                       new OpenLayers.Control.ScaleLine({geodesic: true}),
                       new OpenLayers.Control.MousePosition(),
                       new OpenLayers.Control.LayerSwitcher({'asscending':true}),

                       new OpenLayers.Control.KeyboardDefaults()],
                maxExtent: new OpenLayers.Bounds(-20037508.34,-20037508.34,20037508.34,20037508.34),
                maxResolution: 156543.0399,
                numZoomLevels: 19,
                units: 'm',
                projection: new OpenLayers.Projection("EPSG:900913"),
                displayProjection: new OpenLayers.Projection("EPSG:4326")
            } );

            var MyMapnikLayer = new OpenLayers.Layer.OSM("myMapnik", "file:///D:/Tiles/myMapnik/${z}/${x}/${y}.png", {numZoomLevels: 16, alpha: true, isBaseLayer: true, visibility: true});

It is added for the map and for the layer object. Both can be different (and every layer may have a different level below the map elements zoom level).

  • I have tried it, but it did not work. After that, I decided to set the bounding box MANUALLY and it worked. I suppose there must be a more 'elegant' way to do it via OpenLayers. Thanks a lot for your time. [anyway, your answer is useful. I can not do it, due to lack of reputation :(]
    – Andy
    Jan 13, 2014 at 7:47
  • You have to add it twice, see my extended answer. If you accept the answer, you might have gained enough reoutation to give answers yourself.
    – AndreJ
    Jan 13, 2014 at 8:01

I found the simplest way to restrict the maxZoom levels for a XYZ layer was to override the getNumZoomLevels method:

  function zoomChanged()
        var coor_from = new OpenLayers.Projection("EPSG:4326");
        var coor_to   = new OpenLayers.Projection("EPSG:900913");
        var level = map.getZoom();
        var center =   map.getCenter()
        var zoomLevel = level;
        var valid =false;
        map.getNumZoomLevels = function(){ return 16; };
        map.isValidZoomLevel = function(zoomLevel) {
            valid = ( (zoomLevel != null) &&
            (zoomLevel >= minzoom) &&
            (zoomLevel <= maxzoom) );
            if(!valid && map.getZoom() == 0){
                map.zoomTo(maxzoom - (maxzoom - minzoom)/2);

            return valid;
            SetCenterPoint(center.lat, center.lon, map.getZoom());
        return valid;
  • It's a good idea. Thank you for your suggestion @Vijay. Greetings from Indonesia.
    – Andy
    Jun 9, 2016 at 11:17

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.