MapKit and Core Location | raywenderlich.com

Want to take your app to the next level? In this video series, you’ll learn how to incorporate both location and map features not only to tell your users where to go, but also what they'll find when they get there. This series covers the basics of working with Core Location, along with awesome MapKit features such as providing turn by turn directions and 3D flyover maps.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/9236-mapkit-and-core-location

Hi Brian,

I’m facing a problem with the requestLocation() call on iOS 12.

Normally one requestLocation() call leads to one event for the locationManager( didUpdateLocations) delegate method. Unfortunately, on a real device from time to time there are several events generated, thus the delegate method is called several times.

Is there a way to figure out the very last call of the delegate method? Using the timestamp associated with every location that is forwarded to the delegate method is not an option. That is based on the fact, that one call of the requestLocation() method will generate on event with an already cached location object with a timestamp that is before the time the requestLocation() call was made.

Thanks
Peter

Yeah, that’s an interesting scenario. Are the returned locations different?

Personally, I’d research why this happening first. Is this happening to just one device are you seeing this on other devices as well? And of course, what is the reason for the delegate being called multiple times. I’d check out the Apple developer forums and see if other people are seeing similar behavior. I hope that helps!

Hi Brian,

the locations are almost the same, only the accuracy get’s better with every response. This is happening on all devices I’ve checked so far.
I assume that the repeated calls of the delegates method comes from the fact that the system tries to improve the accuracy be incorporating information from the position of W-LAN-Systems and GPRS systems. These information has to be fetched via internet from Apple-servers.
As each of the delegate method calls shows an increased accuracy and the information from the Apple-Servers are used to increase the accuracy of the raw GPS data these repeated calls might be arise from this way to improve the accuracy.

This is just an assumption
Peter

The behavior you describe sounds a lot like you have a call to startUpdatingLocation() somewhere.

Even if you don’t, you could try putting a call to stopUpdatingLocation() right before the call to
requestLocation(). That would stop any ongoing updating.

If that is not it, you are not getting the correct behavior from requestLocation(), but I have not seen or heard of it behaving differently anywhere else.

HI,

there is no call of startUpdatingLocation() in the program!

Best regards
Peter

@bdmoakley Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi, I was looking for some information about the pricing and requests limit in MapKit, but I couldn’t find anything in the documentation. Are there any limitations like in google maps, or everything is free?

Best regards
Kacper

Per the documentation, there doesn’t appear to be any hard limits per say. But it appears that excessive requests could result in an app being throttled.

“There are no request limits per app or developer ID, so well-written apps that operate correctly should experience no problems. However, throttling may occur in a poorly written app that creates an extremely large number of requests.”

I’ve seen that, but I wasn’t sure of that. Thanks for the confirmation.