MKMapView default region or copy/duplicate initial state? - ios

After creating a Map View in the storyboard, the default location on the simulator shows up as the United States. Looking from other SO posts, there seems not to be a way to replicate this image since we are not given the default span or region (or any way to access the user's current country and get the corresponding region and span data).
The default map view for the US looks like this:
Is there a way to copy or duplicate the initial state of the map view, so that we can restore it later?
I currently have a "reset" button, but I'm not sure what to reset to. Perhaps make the default region/span the user's current location, if there are no better solutions?

Related

Creating Custom Map based on User Input

I'm trying to create a campus navigation app for my college, and in order to do so I need to make a custom map (or use Apple's, but I'd rather make my own), how exactly would I go about it? I had an idea to just use my location and walk around, forcing my phone to draw the map for me (using lines and such) but I wasn't sure how to go about it.
Is there anyway to create a map that updates automatically when new routes are added via anyone's phone? Almost like a collaborative map?

Make MapView display normal Apple Maps when I don't have a tile in my MKTileOverlay set

I am working on an iOS map that uses a "custom" map, stored completley in my application so it can always be accessed offline. I am using a custom MKTileOverlay URL to my local file store to make this happen, etc.
However, as my application's map only covers a small geographic area, I would like to have have the MapView display the standard Apple Map in such cases. When I overlay the map and set "canReplaceMapContent" to true, I just get a blank white space for map tiles that aren't present.
I don't really want to set canReplaceMapContent to FALSE, because most of the time a user will be using my (custom) map, so I wouldn't want the overhead of rendering the Apple map that would be completely covered.
Is there any way I can return a "nil" to a function or something to tell MapKit to not use the TileOverlay, and just use the regular Apple map instead?
No, but here's an idea: have two MKMapViews with the same frame, one with your custom map and canReplaceMapContent = YES and the other without and NO. You can hide one and show the other, transferring annotations if necessary, and you might be able to produce a convincing swap.

iOS how to put MKMapView user location marker over annotations?

In my iOS app i am displaying many, big annotations, and i set user location to be shown as well. My problem is, that my markers are so big, they are covering user's position, so it's hidden very often.
My question is - is there any "normal" way to set user location's marker above all the annotations, or i have to display custom annotation for user's position, or else?

What does the 'shows user location' option of Map View do?

I have checked the 'Shows User Location' option of Map View in my storyboard.
I am using the simulator and do not have access to a real device. When I run the code I can see the blue icon in my map defaulted to California as you expect.
I was wondering whether this blue icon updates on a real device? Does it move when the user is moving?
Or is there additional code that must be put in to make it work?
The storyboard option correspond to the showsUserLocation property of MKMapView. From the documentation (emphasis added)
This property does not indicate whether the user’s position is actually visible on the map, only whether the map view should try to display it. Setting this property to YES causes the map view to use the Core Location framework to find the current location and try to display it on the map. As long as this property is YES, the map view continues to track the user’s location and update it periodically. The default value of this property is NO.
Of course, this assumes location services are on and the user granted the app the access to them.

iOS - Auto and manual Map routing with user motion and area calculation

I am working on an iOS app whose functionality is to show google map with user current location. I successfully shown user location on map, now I need to draw a route as user moves from current location to another and then to next. Finally at the end on a button click I have to connect very fist location to last location. At the end I need to calculate the drown area in acres.
So I summarize my questions as follows :
How to draw user movement on map?
How to direct connect first and last location on a button click?
How to calculate user moved area?
If I want to draw route from last point to current point on manual click, how to do that?
Please provide any suitable code as well. I would appreciate your efforts.

Resources