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.

I'm implementing a baselayer to be used by a Plone addon (collective.geo.openlayers). My implementation specifically creates a layer and returns it to the addon, which enables many different layers to be configured through a webinterface.

I got it working well, but there is one problem I'm facing that I cannot wrap my head around.

The map displayed is a small local map which only shows tiles when zoomed in to zoom level 11 and higher. For this reason I would like to limit the user from zooming out farther than that.

But when I try to add maxZoomLevel, minZoomLevel or numZoomLevels to the layer definition I get type errors in the getTileInfo function because Openlayers is trying to access the longitude of the tileOrigin property which for some reason is null.

I tried different suggestions about limiting the zoom level but to no avail.

Does anyone know how to limit the zoom levels in the following layer definition?

I cannot simply work around the issue by doing something to the map instance itself, as I only control the layer creation.

function() {

var zugmap_matrixids = [{ 
        identifier : 0,
        topLeftCorner : new OpenLayers.LonLat(919690.324327, 5987771.047746)
    }, {
        identifier : 1,
        topLeftCorner : new OpenLayers.LonLat(929474.2639475, 5987771.047746)
    }, {
        identifier : 2,
        topLeftCorner : new OpenLayers.LonLat(929474.2639456, 5987771.04773376)
    }, {
        identifier : 3,
        topLeftCorner : new OpenLayers.LonLat(931920.24885072, 5985325.06282864)
    }, {
        identifier : 4,
        topLeftCorner : new OpenLayers.LonLat(931920.24885072, 5984102.07037608)
    }, {
        identifier : 5,
        topLeftCorner : new OpenLayers.LonLat(932531.745078525, 5983490.57415958)
    }, {
        identifier : 6,
        topLeftCorner : new OpenLayers.LonLat(932837.49319014, 5983184.82603666)
    }, {
        identifier : 7,
        topLeftCorner : new OpenLayers.LonLat(932990.36724671, 5983031.95198009)
    }
]; 

var layer = new OpenLayers.Layer.WMTS({
    name : "LuftbildPlus+",
    url : [
        "http://webdienste.zugmap.ch/OrthofotoPlus_tiled/service.svc/get"
    ],
    layer : "LuftbildPlusGoogle",
    matrixSet : "LuftbildPlusGoogle",
    matrixIds : zugmap_matrixids, 
    tileFullExtent : new OpenLayers.Bounds(919690.324327, 5948635.289264, 978393.96205, 5987771.047746),
    maxExtent : new OpenLayers.Bounds(919690.324327, 5948635.289264, 978393, 5987771),
    style : "default",
    format : "image/png",
    isBaseLayer : true,
    zoomOffset : -11,
    //numZoomLevels: 8
});

return layer
}

You'll notice that numZoomLevels is commented out. I feel like this should be the correct property to set as the matrices only contain 8 levels, but if I uncomment it, I get the type error I was talking about. If I don't use numZoomLevels or any other property that controls the zoom the map works fine.

share|improve this question
add comment

1 Answer 1

Here is a link to an example that helped me : http://www.wightpaths.co.uk/ In my case the key was to define the 'resolutions' array with all resolution I let people watch and also I wanted the minimum zoom to be the 7th so I defined 'zoomOffset' at 7.

Look at my code :

  var ign= new OpenLayers.Layer.WMTS(
  {
    name: "IGN Ortho",
    url: "http://gpp3-wxs.ign.fr/mykey/wmts",
    layer: 'ORTHOIMAGERY.ORTHOPHOTOS',
    style: 'normal',
    matrixSet: "PM",
    format:'image/jpeg',
    resolutions: [1222.9924523925781,611.4962261962891,305.74811309814453,152.87405654907226,76.43702827453613,38.218514137268066,19.109257068634033,9.554628534317017,4.777314267158508,2.388657133579254,1.194328566789627,0.5971642833948135,0.29858214169740677],
    zoomOffset: 7,
    attribution: 'provided by IGN',
    exceptions:"text/xml"
  },
  {
    isBaseLayer: true,
    units: wm.getUnits()
  }
);
share|improve this answer
add comment

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.