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.
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.
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!
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.
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, 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?
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.”