Lena wrote:If I leave LocationSensor1->Active = true event OnGeocodeReverseEvent happens a lot of times.
Only if you geocode often. Just because you may get a lot of OnLocationChanged events triggered does not mean you have to geocode every one of them. Throttle your calls. You don't need to geocode every individual coordinate change. People tend to stay in one place for arbitrary periods of time, especially times when they are at home or work or whatever, so their location shouldn't change very much, or it will change in small increments at a time, depending on the granularity of the device's GPS receiver.
Lena wrote:I read that the Google does not like when they often read geodata (no more than 2500 per day).
At worse, that works out to ~1-2 requests per minute over a 24 hour period. You could easily throttle your code to limit how many requests you make, say 5-10 per minute for instance. Then you would be making only a few hundred requests a day, instead of a few thousand.
But, if you take into account that location shouldn't change very much, or it will change in small increments, you can reduce how many requests you make per 24 hours. The OnLocationChanged event gives you previous and current coordinates, so you can easily calculate the distance the device has moved between each GPS update. Maybe you don't geocode until the device moves more than a set distance at a time, say 1-5 miles at a time.
Apple's documentation says:
- When you want to update the location automatically (such as when the user is moving), reissue the geocoding request only when the user's location has moved a significant distance and after a reasonable amount of time has passed. In general, you shouldn’t send more than one geocoding request per minute.
- Don’t start a geocoding request if the user won’t see the results immediately. For example, don’t start a request if your app is in the background or was interrupted and is currently in the inactive state.
So, if your app is hidden/in the background, don't geocode again until it comes to the foreground, and then update your UI for the current location.
To take that a step further, if geocoding says the device is not even in the USA at all, you don't need to geocode again for a long while, maybe even not for hours at a time (at least the fastest time needed to reach Colorado from the West or South borders of the USA, which are the closest USA borders to Colorado).
Even if the device is in the USA, you can geocode less often if the device is not in Colorado or its immediate surrounding states (Wyoming, Nebraska, Kansas, Oklahoma, Texas, New Mexico, Arizona, or Utah). Once the device is in one those states, then geocode a little more often to detect if/when the device crosses Colorado's border.
Or, you could just hard-code the known coordinates of Colorado's borders (or at least its 4 corners, since it is a fairly rectangular-shaped state), and then geocode only when the device is within a set distance of those borders, say 5-10 miles for instance.
In other words, throttle how often you geocode based on how close or far the device's current location is to Colorado. The farther away the location is, the less often you need to geocode. The closer the location is, the more often you need to geocode. Be strategic in your use of geocoding, don't just use it blindly.
Lena wrote:It's hard for me to use ios api...
I suggest you learn how. Start by looking at TGeocoder's own source code, porting it from Delphi to C++, and then tweak it for the extra parameters you need.