MapCache icon indicating copy to clipboard operation
MapCache copied to clipboard

Retina tiles are not used as they are with the native renderer

Open karlbeecken opened this issue 3 years ago • 2 comments

Hi,

I tried to integrate this library in my project. It uses OpenRailwayMap tiles, which are 512x512 retina png tiles (e.g. https://a.tiles.openrailwaymap.org/standard/8/137/85.png). If I use the native MKTileOverlay (first example) it uses the full available resolution on a retina display, resulting in a sharp image with more details. If I use the MapCache overlay (second example), the tiles are blurry and have way less details. I assume something in the zoom height configuration on retina displays is wrong here, but I couldn't figure out what exactly. Maybe @merlos you can take a look what could be the problem here?

If it helps, I can provide the code I used to achieve both outcomes.

Thanks!

Example 1 Example 2

karlbeecken avatar Nov 27 '22 13:11 karlbeecken

Hi,

One question, did you update the MapCacheConfig tile size?

    ///
    /// Tile size of the tile. Default is 256x256
    ///
    public var tileSize: CGSize = CGSize(width: 256, height: 256)
    

https://github.com/merlos/MapCache/blob/13283eaeec68951f330a1229e0bb4ae23e05c789/MapCache/Classes/MapCacheConfig.swift

merlos avatar Nov 28 '22 05:11 merlos

Hi, yes, I set it (see complete example below). If I do not set it, the tiles overlap each other (-> each tile gets drawn beginning at 0,0 coords, overflowing the 256x256 rect and overlapping the neighbouring tiles).

Btw, I set canReplaceMapContent = false in MKMapView+MapCache to achieve the overlay functionality.

        var config = MapCacheConfig(withUrlTemplate:"https://{s}.tiles.openrailwaymap.org/standard/{z}/{x}/{y}.png")
        
        config.maximumZ = 19;
        config.cacheName = "standard";
        
        config.tileSize = CGSize(width: 512, height: 512)
        config.overZoomMaximumZ = false;

        let mapCache = MapCache(withConfig: config)

                
        mapView.useCache(mapCache)

karlbeecken avatar Nov 28 '22 16:11 karlbeecken