Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
karlbeecken opened this issue Nov 27, 2022 · 2 comments
Open

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

karlbeecken opened this issue Nov 27, 2022 · 2 comments

Comments

@karlbeecken
Copy link

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

@merlos
Copy link
Owner

merlos commented Nov 28, 2022

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

@karlbeecken
Copy link
Author

karlbeecken commented Nov 28, 2022

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants