Reputation: 4107
I am using a MKTileOverlayRenderer
to render my own tiles with MapKit. In areas where my tiles don't cover, the empty grid is shown, which is exactly what I'm looking for. However, all names of places (labels of landmarks) get also shown. I would like to hide these to provide an empty space beyond the confines of my tiles.
This is how I am initializing the mapView:
let overlay = MapOverlay(map: map)
// MapOverlay is my own subclass of MKTileOverlay, map is a Swift struct including url scheme to retrieve the tiles
overlay.canReplaceMapContent = true
// I intend to have empty content beyond my tiles
tileRenderer = MKTileOverlayRenderer(tileOverlay: overlay)
mapView.addOverlay(overlay, level: .aboveLabels)
// I want my tiles to be laid over all other content
This is how it shows around the borders of my tiles in MapKit:
I know it's possible to use a placeholder tile for areas beyond the region of interest, which would cover, in principle, the empty grid and the landmark label names. This is problematic though for 2 reasons:
For these reasons, I chose to use a transparent placeholder tile.
Is there a way to hide the landmark label names?
Upvotes: 1
Views: 371
Reputation: 4107
I couldn't find a way to prevent MapKit from showing the label names for landmarks (and the canReplaceMapContent
property hides the map content but not the labels), but I figured out why covering beyond the region of interest was leaving gaps: the original tiles had transparency around the edges of the region of interest.
A way to cover the landmark label names is to provide solid color in the edges of the region of interest in the generated tiles, and use a placeholder tile with the same solid color for areas beyond the region of interest. Therefore, no code changes needed, just to regenerate the tiles with solid color around the edges.
This still has the issue of small glimpses through the map when zooming, panning, which is not great, but I can't see no way around that.
Upvotes: 2