Question

Please see below image:

enter image description here

As you can see, I added a mkpolyline to my mkmapview but because the route is to big so part of the route has been move behind the other subviews.

I want to make a change so that for all times, the positions of the poly-line be at bottom half of the map view(at below of the uitable that shows step instructions). Is it possible?

Was it helpful?

Solution

You need to zoom the map view out in order to have the route displayed below the route text view(s). There are 2 ways to do that generally:

  1. Determine the new MKCoordinateRegion (or MKMapRect), which is the bounds of your route with extra padding space above
  2. Change the MKMapView frame such that it sits below the route text views and maintain a region which fits the route

Option 2 is easier, but has a different visual effect. Option 1 requires you to pad the display area while maintaining the route display area.

For option 1, use the fact that you already zoom the map to the route and manipulate the visibleMapRect. Try:

MKMapRect visibleMapRect = map.visibleMapRect;
visibleMapRect.origin.y = visibleMapRect.size.height;
visibleMapRect.size.height *= 2;
map.visibleMapRect = visibleMapRect;
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top