Hiding label names in MapKit when using MKTileOverlayRenderer - ios

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:
When zooming in/out or panning, and for the split second it takes to load the tile, it shows the content below, which is disorienting
the placeholder tile doesn't blend seamlessly with the provided tiles of the region of interest, which leaves gaps through which you can still see the empty grid and the landmark label names
For these reasons, I chose to use a transparent placeholder tile.
Is there a way to hide the landmark label names?

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.

Related

Issue with MKOverlayView

We are working on MKOverlayView, below is the expected functionality:
An image has to be overlaid on the map and has to be tilted by a certain angle (bearing).
Issue: When the map is zoomed to the maximum level, one of the corners of the overlaid image is getting truncated. But, Complete image is coming back when zoom out a little bit.
Please find the attached screenshot for reference.
I'm also getting overlaying text being clipped at any zoom level. What I noticed is that it clips at some vertical invisible lines. Those invisible lines, they look like as if they were the actual map tiles.
What it still works is other overlays I have on the map, they don't get chopped.
This started to happen with iOS 10.
In the image, the building outlines –colored- are overlays that don't get clipped, but the text overlays (drawn using drawInRect) they do get chopped. Texts are Very Long text1 to see if it truncates, changing text1 for text2 and so forth.

Can a map overlay be moved?

I'm displaying several user's locations on a map simultaneously as circles of different colors.
I can do this using an annotation and then when the user's location updates use UIView:animateWithDuration: to move to their new location.
However there is a requirement that the size of the circles reflects the accuracy of the location i.e. very accurate equals a circle of size 10 meters, rough accuracy is represented as a circle of size 500 meters etc.
However there are two problems using annotations for this - the first is how to transform meters into a CGRect on the correct size to draw on the map. And the second is the annotations need to be resized if the user zooms the map.
So I was looking at using an overlay instead as that already has a radius and automatic resizing during zooming built in so it handles those two problems.
However it looks like overlays are meant to be static and their coordinate property is read only.
Is there some way I can make the overlays move as the user's location moves? (other than completely remove it and re-add it?)
[THis is for iOS 7 only]

iOS Maps - Grid Overlay

I'm looking for a way to overlay the iOS maps with a grid. The complete earth needs to be divided into squares. The location of the user doesn't effect the placement of the squares (In other words; the squares are always placed the same. On every iPhone, no matter where the user is).
I Looked into MKOverlay, but I've never used this so it's very new to me. Also, when zooming in/out should effect the overlay. It's very important that the squares are always covering the same area on the map (For example; A square should be 100mx100m in real world, when you zoom out, the square should cover the same 100x100).
Is there anybody that can point me in the right direction?
Is it possible to draw the grid from een .xml? Example given; On .XML is holding all squares with their coordinates on the map. When the user loads the map, the 100 squares around the user are loaded.

ios sdk MKMapView overlapping pins?

I have map view and many pins on it.
When the map view is zoomed out, I group overlapping pins into 1 (and show in label total count of pins in it).
But what to do, if map view is max zoomed in, and pins are still overlapped?
How can I shift them while they do not overlap each other ?
Something like this:
Or is there another solution?
In a slightly different solution to the same problem, the demo in the WWDC 2011 #111 - Visualizing Information Geographically with MapKit video (the demo is a little more than 18 min into the video) illustrates an example of how you can prevent overlapping annotations (including some nice animation revealing and hiding more detailed annotations as you zoom in and out).
What they do is to break the mapview into a grid of a particular size (I think they use 60px), and if they are too close, they pick one for that grid and hide the others. They also do a graceful hiding of the annotations as you zoom out (so you can see the annotations that are being hidden fly into the visible annotation for that group). As you zoom in the annotations are unhidden, you see it fly out of the one central annotation for that grid.

Adjust MkMapView Annotation

I'm adding annotations to an MkMapView and am using a custom image to do so. My custom image is box shaped with a little triangular arrow that's supposed to be right on the place that's being annotated. It seems like MapView by default annotates using the geometric center of the image. What's the best way to design around this problem? Manually moving the icon? Creating the icon in a specific way?
Here's the Apple docs for MKAnnotationView's centerOffset property:
By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in pixels. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.

Resources