[mapguide-users] Mapguide & Openlayers 3.12.1 Displaydpi for mobile/tablet devices

RenoSun renolionheart at gmail.com
Sun Jan 24 13:22:28 PST 2016


I am currently trying to update our mobile map viewer (Kaliopa Mapguide
Mobile Viewer) from OL2 to OL3.

I found there is no display problems for mapguide layer on the desktop
browsing.

However, when I zoomed in higher zoom levels on the mobile devices, the
features on the mapguide layers such as points, labels, and lines are
displayed so small.

I tried to use the custom resolutions array for mobile devices, and it works
as following:

   var DesktopResolutions = [156543.03390625, 78271.516953125,
39135.7584765625,
              19567.87923828125, 9783.939619140625, 4891.9698095703125,
              2445.9849047851562, 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.2986, 0.1493];
    var MobileResolutions = [156543.03390625, 78271.516953125,
39135.7584765625,
              19567.87923828125, 9783.939619140625, 4891.9698095703125,
              2445.9849047851562, 1222.9924523925781, 611.4962261962891,
              305.74811309814453, 152.87405654907226, 76.43702827453613,
              38.218514137268066, 19.109257068634033, 9.554628534317017,
              4.777314267158508, 2.388657133579254, 1.194328566789627,
              0.5971642833948135];

var mgLayerSource = new ol.source.ImageMapGuide({
        projection: 'EPSG:3857',
        url: agentUrl,
        useOverlay: true,
        hidpi: true,
        metersPerUnit: metersPerUnit,
        displayDpi:  DPI, //  default 96
        units: unitsType,
        ratio: 1,
        resolutions: (isMobile ? MobileResolutions : DesktopResolutions),
        params: {
            mapName: mapName,
            session: sessionId,
            selectioncolor: selectionColor,
            behavior: 2,
            locale: locale,
            VERSION: "2.1.0",
            clientagent: clientAgent,
            format: 'PNG',
            showGroups: '',
            hideGroups: '',
            showLayers: '',
            hideLayers: ''
        }
    });

    mgLayer = new ol.layer.Image({
        title: 'Mapguide Layer',
        extent: bounds,
        source: mgLayerSource
    });

It works to show larger features, but won't refresh the mapguide layer when
I zoom over zoom level 18.

Therefore, I don't like the solution above.

Then, I found out that if I change the display DPI, it will work just fine
on most of the devices.

        displayDpi: (isMobile ? 300: DPI),
        units: unitsType,
        ratio: 1,
        //resolutions: (isMobile ? MobileResolutions : DesktopResolutions),

Hope this help someone works on the similar projects, or please let me know
if there are more responsive solutions.

Thanks a lot!







--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Mapguide-Openlayers-3-12-1-Displaydpi-for-mobile-tablet-devices-tp5247003.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list