Manually show current location blue dot MKMapView ios - ios

I'm building an iPhone app. There is a screen with a map (MKMapView) always showing. But to preserve battery, I don't want user location to be updated all the time, only automatically (every 15 minutes) and manually (onclick).
But, I also want to show this user location on the map.
The problem is, if I showsUserLocation for my MapView, it automatically starts updating location, hence drains battery.
I tried activating the showsUserLocation option, saving the MKUserLocation, then deactivating the showsUserLocation then adding the saved MKUserLocation as an annotation by hand, but it actually shows a WARNING and reactivate the showsUserLocation option !
So I guess the last way is by hand:
I built a blue dot annotation myself but it doesn't have the glowing effect and the accuracy circle around. Do you have any idea how to do this? Or if there is any other way, please share.
Thanks !

well you will have to go with your 'last way' -- MKAnnotationViews can easily be animated -- just treat it like any UIView :) there
see MKMapView current location showing as custom pins for how to mae custom Pins

Just use native flag to enable this like so:
[mapView setShowsUserLocation:YES]

If you want some help on the user location annotation stuff, check out how it's done in MapBox:
http://mapbox.com/mapbox-ios-sdk
In particular you want RMUserLocation. The whole SDK is open source.

Related

Using MKMapView with a custom MKOverlay. Can the local attractions that come with Apple Maps by default appear above the overlay layer?

I have an MKMapView with an MKOverlay on top, I'm wondering if its possible to have road names, place names, places of interest and everything like that, that comes by default with Apple Maps, can be displayed above my MKMapView so I don't have to add all this information manually as annotations. I know this is possible with the Google Maps API on Android so wasn't sure if I could do this with Apple Maps.
I've added an image that shows iOS versus Android to show what I am envisioning:
So, I've found a solution to this issue. If you're using the addOverlay: method in MKMapView, you can use:
[self.myMapView addOverlay:customOverlay level:MKOverlayLevelAboveRoads];
MKOverlayLevelAboveRoads means place labels including shields and point of interest icons are shown above your overlay.
MKOverlayLevelAboveLabels means your overlay will appear on top of everything (which i believe is the default based on my experiences).

Long-tap/drag/drop Skobbler skannotation to new position

I'm looking to allow my users to drag & drop annotations on my maps, initiated by a long-press on the annotation pin. I can't find anything in the documentation that would handle this.
Can someone point me in the right direction?
Edit: I realize I may not have been as clear as I thought I was.
Currently, my users are able to add new annotations to the map by long-pressing at a location on the map. I'd like for them to be able to move those annotations to a different location.
For adding a new PIN, the SKMapViewDelegate protocol is used to receive map-related update messages.
Check: http://developer.skobbler.com/docs/ios/2.4.0/Protocols/SKMapViewDelegate.html

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.

Resources