Proper way of showing/hiding map overlays - iphone

I have a custom overlay that trace the user location changes. I want to show/hide the overlay. What's the proper way of doing that?
I'm using hidden property of overlay view to show/hide it right now, but it doesn't work very well. When i pan and zoom on the map i see bits and pieces of overlay (even when i've set hidden property to TRUE).

Instead of showing/hiding the overlay, i ended up adding/removing the overlay which seems to be working fine (in most cases).

Related

How to get the visible view size in iOS13 when presenting a view controller

In iOS13, the default way when presenting a view controller was changed to the "sheets/cards" view. As I’m not using auto layout (why not, is not really important and relevant), I rely on getting position of elements based on the frame of the view.
Now, the problem with the new method is, that the view frame doesn’t really reflect the actual content size visible on the screen anymore. E.g. if I have positioned a UIButton at the bottom on the view controller based on the view.frame bottom coordinate, it will be now cut off, as the view is actually moved down in the amount of the nice "sheets/cards" visual indication at the top. The same problem is even more evident in an iPad, where centring another view in the view controllers view will be offset, due to the fact that the default presentation style is now a "sheet" in the middle of the screen.
I’ve currently changed everything to force the full screen version, but it would be nice to use the new fancy design.
Anybody has any idea how to get the actual visible rect/coordinates in the new style without changing things to auto layout?
Here are how they look. The "flower" is centered in the view and the X button should not be so close to the bottom or missing completely in the iPad version.
Finally figured it out. As I was setting the positions of items in viewDidLoad, the frame was not calculated correctly, thus resulting things being laid out incorrectly. When resetting the frame and positions in viewDidLoadSubviews, the positions were placed correctly.

Adding a Stationary Button Overtop of a Map View

I have a really quick question which is probably ridiculously simple. I currently have an application that I am using route-me and OpenStreetMap, and basically I have a view that loads the map into the entire window.
When trying to run the project with a button added to this view in Interface Builder, the map loads overtop of the button, and is not displayed.
The map view is loaded by a custom class RMMapView (route-me class), and I already know how to add markers to the map itself, but not a stationary button in the corner of the screen that won't move as the user drags the map around. I want to add the button as an overlay, a view overtop of the map view itself.
If you guys could give me any tips on how to do this I would greatly appreciate it.
Thanks.
[mapView bringSubviewToFront:button];
Maybe this helps.
Add the mapView as a subview to a view, and add the button as a subview to the same view.
In Interface Builder, on the left side pane that has all the scenes, switch the positions of the button and the MapView. If the button is listed above the MapView, drag it down so it's below it.. or vice versa. This will change which view is on top of the other.

Can we Add a new layer over CATiledLayer?

I am displaying a big image in CATiledLAyer.
Now i want to draw a line between two points where the user touches on that image.
Would that be possible ?? , if so can you outline me the way to accomplish it ??
Thanks,
Ratna
I did something similar for an app a while back. The strategy I used was to place another view on top of the view with the tiles. Then set your self up as a UIScrollViewDelegate and everytime the tiled view scrolls or zooms, recalculate where the overlayed objects need to be. Just read the contentOffset value and the zoomScale and you should have what you need to correctly figure out where your overlay needs to be positioned. You will also have to make sure that touches are correctly reaching the tile view if they have to pass through your overlay view.

iOS Map pin bubble out of screen

When i click on a pin on the map and if the pin is on the borders of the iPhone screen, the bubble comes off the screen, i.e. Half ourside of the viewport and half inside the viewport.
Is there is any property etc which will show the bubble automatically centered on the screen.!
Check this image below to know more about what i mean
http://i.stack.imgur.com/ZSWmZ.png
Any help will be highly appreciated.
You can try to make it so that everytime an annotation is selected, you change the map's center coordinate to the coordinate of your annotation? Instead of calculating the pop up view's dimensions, just do it every time instead. Here's the code to do this. Put this into your delegate for MKMapView
- (void)mapView:(MKMapView *) theMapView didSelectAnnotationView:(MKAnnotationView *)annoView{
[theMapView setCenterCoordinate:annoView.annotation.coordinate animated:YES];
}
Once you've done this, you should be all set.
Also, it's curious to note, that when I tried implementing a mapview, and I added annotations, whenever I selected them, the map automatically moved so as to display the whole calloutView. I wonder why yours isn't doing that. Anyway, if my answer helped, please accept it as your answer. Thnx
Mapkit does a great job of positioning the map when annotations are selected but it can't magically account for other UI elements you've placed in the scene that are obscuring things.
You need to either resize your mapview when your search box is down so it is not obscuring it or you need to add logic to reposition the map if a annotation is selected which is near the top of the view when the search box is visible.

How can I specify where I want my UI elements to go on orientation change in Interface Builder?

Ok so I know this is a bit of a newbie question, but being that I am a newbie its ok! I have a view that I am trying to make orientation friendly in IB, and I am having some difficulties.
I have everything looking nice in portrait of course, but then when I go to landscape mode (by hitting that arrow in the top-right corner) everything gets all messed up.
Now, because of the way the view is laid out, I need to align 3 buttons along the bottom of an image view in portrait, and then in landscape, those three buttons need to be symmetrically aligned along the right side.
No combination of fiddling with those red arrows in the size inspector are rewarding me the results I am seeking. Is it possible to set up the buttons one way in one orientation in IB, and then on change, set them completely different?
I have looked all around for a useful IB tutorial, but haven't been able to find anything.
I know you want to do this in IB, but if you're willing to try it programmatically, then you can move things around pretty easily. For your buttons, just implement the setCenter method like this:
[myButton setCenter:CGPointMake(xCenter,yCenter)];
Otherwise, if you want to use the IB, use the Autosizing options. The arrows will stretch or compress the width and height, and the bars (|-|) preserve distances from the top and bottom. If you have three buttons in a row, you can fix the left distance for the left button, the right distance for the right button and both/neither for the center button. Something like that may work.
The third option is to make a new view, call it landscapeView or something, by dragging a UIView from the library to the window with File's Owner, First Responder, View, etc. Then orient that to landscape, copy over all your UI objects, lay them out as you like, and when you rotate, replace the current view with landscapeView. The problem with this that I've found (one of many) is that you have to reconnect everything and have different IBOutlets for the labels and whatnot. T
Using IB's autosizing features can only do so much. PengOne does a good job of describing them in his second paragraph. If they are not enough, you have to move the elements programmatically. See Responding to Orientation Changes. Otherwise, you can just use a completely different view, again as mentioned by PengOne.