3

I have the code shown below that works perfectly on a desktop, but will only display the OSM layer on a mobile device.

Am I missing something obvious?

My understanding is that it should work on both with no adjustments.

Devices tested include IPhone, IPad and Android, with a couple of different browsers.

I am working with OpenLayers Version 3.0.0 (release version)

I know the buffer and isBaseLayer parameters may be unnecessary, trying to figure that out now in the documentation.


I figured out it was a tile size issue. I am using GeowebCache which expects a tile size of 256, but it is returning the following error ONLY when used on a mobile device

400: The requested tile dimensions 384x384 do not match those of the grid set (256x256)

I found this code in an obscure email thread, but it appears map.tileOrigin is undefined:

          tileGrid: new ol.tilegrid.TileGrid
                ({
                origin: [map.tileOrigin[0], map.tileOrigin[1]],
                resolutions: map.resolutions,
                tileSize: 256,
                }),






    // Base Map
      Mware_Layer_OSM = new ol.layer.Tile({
            title: 'OpenStreetMap',
            isBaseLayer: true,
            preload: Infinity,
            buffer: buffer,
            source: new ol.source.OSM()
      })



    // Layer Group
      Mware_Layer_PCodes = new ol.layer.Tile({
        title: 'PostCodes',
        preload: Infinity,
        buffer: buffer,
        source: new ol.source.TileWMS( ({
          urls: urls,
          params: {'LAYERS': Required_Layer, SRS:'EPSG:3857', 'TILED': true, format: 'image/' + Image_Format},
          serverType: 'geoserver',
          visible: true
        }))
      });


    // View
    view = new ol.View({
        center: transform(startLon, startLat),
        zoom: Initial_Zoom
    });

    // Create the Map
    map = new ol.Map({
        target: target_div,
        layers: [Mware_Layer_OSM, Mware_Layer_PCodes],
        renderer: 'canvas',
        view: view,
        controls: ol.control.defaults({
            attributionOptions: {
            collapsible: false
          }
        }),


    });

1 Answer 1

6

The error message means that you are using a WMS-C tile service which does not support the pixel ratio of the mobile device you were trying. To fix this, just remove the serverType config option of your ol.source.TileWMS.

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.