marcick Well-Known Member Licensed User Longtime User Mar 17, 2016 #1 I'm doing a massive use of geocoder (Ilocation library) and tuning my app to not exceed the usage quota. Actually I have a 300mS timer that delay each Geocoder request, it should be enough (the quota seems to be 2500 requests per day, 10 requests per second max) but after some requests I obtain this exception in Geocoder_Complete: Code: <B4IExceptionWrapper: Error Domain=kCLErrorDomain Code=2 "(null)"> Then I continue to call the geocoder and after some seconds it starts to work again. The Google Developer Console shows some graph of the request per second, but it seems to me they are only referred to the GoogleMap usage, not the geocoder. Does the Ilocation library use the same API Key declared in the app ? I suppose yes, but why I can't see in the graph the massive geocoder request that My app is generating ?
I'm doing a massive use of geocoder (Ilocation library) and tuning my app to not exceed the usage quota. Actually I have a 300mS timer that delay each Geocoder request, it should be enough (the quota seems to be 2500 requests per day, 10 requests per second max) but after some requests I obtain this exception in Geocoder_Complete: Code: <B4IExceptionWrapper: Error Domain=kCLErrorDomain Code=2 "(null)"> Then I continue to call the geocoder and after some seconds it starts to work again. The Google Developer Console shows some graph of the request per second, but it seems to me they are only referred to the GoogleMap usage, not the geocoder. Does the Ilocation library use the same API Key declared in the app ? I suppose yes, but why I can't see in the graph the massive geocoder request that My app is generating ?
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2016 #2 The Geocoder is based on Apple service: https://developer.apple.com/library...ocation/Reference/CLGeocoder_class/index.html The rate limits are not documented. Upvote 0
The Geocoder is based on Apple service: https://developer.apple.com/library...ocation/Reference/CLGeocoder_class/index.html The rate limits are not documented.
marcick Well-Known Member Licensed User Longtime User Mar 17, 2016 #3 Oh .. They say "in a typical situation, you should not send more than one geocoding request per minute." ...... How can I use the google API instead ? They have precise and documented rate limits. Upvote 0
Oh .. They say "in a typical situation, you should not send more than one geocoding request per minute." ...... How can I use the google API instead ? They have precise and documented rate limits.
Erel B4X founder Staff member Licensed User Longtime User Mar 17, 2016 #4 It should be quite simple to use Google's Geolocation service with HttpUtils2: https://developers.google.com/maps/documentation/geolocation/intro#overview Upvote 0
It should be quite simple to use Google's Geolocation service with HttpUtils2: https://developers.google.com/maps/documentation/geolocation/intro#overview
marcick Well-Known Member Licensed User Longtime User Mar 17, 2016 #5 Yes. I'll try to implement it Thanks Upvote 0
marcick Well-Known Member Licensed User Longtime User Mar 18, 2016 #6 Ok I have found here the code https://www.b4x.com/android/forum/threads/b4j-question-geocoder.62842/#post-396959 the structure is like this: Code: Sub Geocode(Lat As Double, Lng As Double) ' meke the http request End Sub Sub JobDone (Job As HttpJob) ' here I have the result end sub Non the question is: how can I turn this into a function so that I can write this (from anywhere in my app) ? Code: addr=GeoCode(45,8) Does it require skill in creating libs ? (out of my range ...) Last edited: Mar 19, 2016 Upvote 0
Ok I have found here the code https://www.b4x.com/android/forum/threads/b4j-question-geocoder.62842/#post-396959 the structure is like this: Code: Sub Geocode(Lat As Double, Lng As Double) ' meke the http request End Sub Sub JobDone (Job As HttpJob) ' here I have the result end sub Non the question is: how can I turn this into a function so that I can write this (from anywhere in my app) ? Code: addr=GeoCode(45,8) Does it require skill in creating libs ? (out of my range ...)
Erel B4X founder Staff member Licensed User Longtime User Mar 20, 2016 #7 It is not possible. You cannot hold the main thread until the response arrives. Upvote 0
marcick Well-Known Member Licensed User Longtime User Mar 20, 2016 #8 Understand, thanks. But when I use the geocoding from several modules, do I have to duplicate the code ? I would like to write the code in one place and call it from anywhere. But when I have the JobDone event how can I return to the point the geocoder has been called ? Upvote 0
Understand, thanks. But when I use the geocoding from several modules, do I have to duplicate the code ? I would like to write the code in one place and call it from anywhere. But when I have the JobDone event how can I return to the point the geocoder has been called ?
Erel B4X founder Staff member Licensed User Longtime User Mar 20, 2016 #9 You should never duplicate code. Code: Sub Geocode(Callback As Object, OtherParams...) Dim job As HttpJob ... job.Tag = Callback End Sub Sub JobDone(job As HttpJob) CallSub2(job.Tag, "Result_Arrived", Result) End Sub SomeModule.Geocode(Me, ...) Sub Result_Arrived (Result As ...) Upvote 0
You should never duplicate code. Code: Sub Geocode(Callback As Object, OtherParams...) Dim job As HttpJob ... job.Tag = Callback End Sub Sub JobDone(job As HttpJob) CallSub2(job.Tag, "Result_Arrived", Result) End Sub SomeModule.Geocode(Me, ...) Sub Result_Arrived (Result As ...)
marcick Well-Known Member Licensed User Longtime User Mar 20, 2016 #10 Wow .... Many thanks !!! Upvote 0