Jul 23, 2017 Replies: 16 B4A, B4i and B4J classes are attached. PlacesAutocompleteView is based on SearchView. It calls Google's Places autocomplete API to let the user select a place. Once selected it sends another request to get the exact location. You can get other information as well. B4A project depends on: B4A v7+, IME, JSON and OkHttpUtils2 B4i project depends on: B4i v4+, iHttpUtils2, iJSON and iUI8. - In order to use Google Places API you need to create a project in Google developer console: https://console.developers.google.com/ - Enable Google Places API Web Service api. - Create an API key and set it in Main.Process_Globals. Make sure to go over Google's policies: https://developers.google.com/places/web-service/policies#logo_requirements The usage limits for a free unidentified account are quite low. Once identified the limits are much higher. Attachments B4A_GooglePlacesAutocomplete.zip B4A_GooglePlacesAutocomplete.zip 12.5 KB · Views: 1,392 B4i_GooglePlacesAutocomplete.zip B4i_GooglePlacesAutocomplete.zip 8.9 KB · Views: 919 B4J_GooglePlacesAutocomplete.zip B4J_GooglePlacesAutocomplete.zip 5.9 KB · Views: 949 Last edited: Jul 24, 2017 Click to expand...
B4A, B4i and B4J classes are attached. PlacesAutocompleteView is based on SearchView. It calls Google's Places autocomplete API to let the user select a place. Once selected it sends another request to get the exact location. You can get other information as well. B4A project depends on: B4A v7+, IME, JSON and OkHttpUtils2 B4i project depends on: B4i v4+, iHttpUtils2, iJSON and iUI8. - In order to use Google Places API you need to create a project in Google developer console: https://console.developers.google.com/ - Enable Google Places API Web Service api. - Create an API key and set it in Main.Process_Globals. Make sure to go over Google's policies: https://developers.google.com/places/web-service/policies#logo_requirements The usage limits for a free unidentified account are quite low. Once identified the limits are much higher.
Erel B4X founder Staff member Licensed User Longtime User Jul 24, 2017 #3 A B4J version is now available (based on the new SearchView class):
Magma Expert Licensed User Longtime User Aug 2, 2017 #4 @Erel why b4j class not working. I using my api key... but when typing the list extends or being small without anything in... ? this class is exactly what i need for Addresses... seems that must have limits and bounds if works
@Erel why b4j class not working. I using my api key... but when typing the list extends or being small without anything in... ? this class is exactly what i need for Addresses... seems that must have limits and bounds if works
DonManfred Expert Licensed User Longtime User Aug 2, 2017 #5 Magma said: @Erel why b4j class not working Click to expand... Create a new thread in the questionsforum and post a sample project which shoes the issue. Without seeing what you are doing and how we hardly can´t help.
Magma said: @Erel why b4j class not working Click to expand... Create a new thread in the questionsforum and post a sample project which shoes the issue. Without seeing what you are doing and how we hardly can´t help.
Magma Expert Licensed User Longtime User Aug 2, 2017 #6 @DonManfred just open the example and replace the api key... for me not works for you ?
DonManfred Expert Licensed User Longtime User Aug 2, 2017 #7 Magma said: for me not works for you ? Click to expand... i did not tried it... But i guess you forget to Erel said: - In order to use Google Places API you need to create a project in Google developer console: https://console.developers.google.com/ - Enable Google Places API Web Service api. - Create an API key and set it in Main.Process_Globals. Click to expand... maybe you api-key is not bound to use the Google Places Api Web Service? I´ll check the example this evening. But i´m pretty sure it will work if i setup everything correctly.
Magma said: for me not works for you ? Click to expand... i did not tried it... But i guess you forget to Erel said: - In order to use Google Places API you need to create a project in Google developer console: https://console.developers.google.com/ - Enable Google Places API Web Service api. - Create an API key and set it in Main.Process_Globals. Click to expand... maybe you api-key is not bound to use the Google Places Api Web Service? I´ll check the example this evening. But i´m pretty sure it will work if i setup everything correctly.
Magma Expert Licensed User Longtime User Aug 2, 2017 #8 @DonManfred As always you ve right i tried to use javascript google map api key not google places api key for web ! - it works excellent Last edited: Aug 2, 2017
@DonManfred As always you ve right i tried to use javascript google map api key not google places api key for web ! - it works excellent
M Mike1970 Well-Known Member Licensed User Longtime User May 25, 2019 #9 it's possible to change the "visible" parameter by code?
Csaba Balogh Member Licensed User Feb 4, 2020 #10 How can I get postcodes (ZIP codes ) listed within the result? It is necessary since lot of cities have the same street name with different postal codes. I was trying hard to find out from google's api documentation, but it seems to be very condusing at the moment. Any ideas? Last edited: Feb 4, 2020
How can I get postcodes (ZIP codes ) listed within the result? It is necessary since lot of cities have the same street name with different postal codes. I was trying hard to find out from google's api documentation, but it seems to be very condusing at the moment. Any ideas?
R roerGarcia Active Member Licensed User Longtime User Mar 16, 2020 #11 From https://developers.google.com/place...aries/places/api/model/Place.Type#POSTAL_CODE public static final Place.Type POSTAL_CODE public static final Place.Type POSTAL_CODE_PREFIX public static final Place.Type POSTAL_CODE_SUFFIX public static final Place.Type POSTAL_TOWN public static final Place.Type POST_BOX public static final Place.Type POST_OFFICE And Place types You may restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. The supported types are: the (regions) type collection instructs the Places service to return any result matching the following types: locality sublocality postal_code From https://developers.google.com/places/web-service/autocomplete#place_types Shalom. Last edited: Mar 16, 2020
From https://developers.google.com/place...aries/places/api/model/Place.Type#POSTAL_CODE public static final Place.Type POSTAL_CODE public static final Place.Type POSTAL_CODE_PREFIX public static final Place.Type POSTAL_CODE_SUFFIX public static final Place.Type POSTAL_TOWN public static final Place.Type POST_BOX public static final Place.Type POST_OFFICE And Place types You may restrict results from a Place Autocomplete request to be of a certain type by passing a types parameter. The parameter specifies a type or a type collection, as listed in the supported types below. If nothing is specified, all types are returned. In general only a single type is allowed. The exception is that you can safely mix the geocode and establishment types, but note that this will have the same effect as specifying no types. The supported types are: the (regions) type collection instructs the Places service to return any result matching the following types: locality sublocality postal_code From https://developers.google.com/places/web-service/autocomplete#place_types Shalom.
M Mark Ryan Penafiel Member Licensed User Longtime User Mar 24, 2020 #12 can you limit the search for a particular country example just in philippines
DonManfred Expert Licensed User Longtime User Mar 24, 2020 #13 Check the google documentation of this Api. Place Search (Legacy) | Places API | Google for Developers developers.google.com
Check the google documentation of this Api. Place Search (Legacy) | Places API | Google for Developers developers.google.com
yfleury Active Member Licensed User Longtime User Mar 25, 2020 #14 DonManfred said: Check the google documentation of this Api. Place Search (Legacy) | Places API | Google for Developers developers.google.com Click to expand... I find in google documentation of this api I can search in a circle:radius@lat,lon but I am not sure how I can implement that. Any clue?
DonManfred said: Check the google documentation of this Api. Place Search (Legacy) | Places API | Google for Developers developers.google.com Click to expand... I find in google documentation of this api I can search in a circle:radius@lat,lon but I am not sure how I can implement that. Any clue?
yfleury Active Member Licensed User Longtime User Mar 25, 2020 #15 I find my self... Maybe I am better programmer day after day I modify PlacesAutocompleteView.bas file at line 83 and 84 and it work. Is it a good try? B4X: Copy j.Download2("https://maps.googleapis.com/maps/api/place/autocomplete/json", _ Array As String("input", New, "key", Main.API_KEY, "locationbias", "circle:100000@" & latitudeGPS & "," & longitudeGPS))
I find my self... Maybe I am better programmer day after day I modify PlacesAutocompleteView.bas file at line 83 and 84 and it work. Is it a good try? B4X: Copy j.Download2("https://maps.googleapis.com/maps/api/place/autocomplete/json", _ Array As String("input", New, "key", Main.API_KEY, "locationbias", "circle:100000@" & latitudeGPS & "," & longitudeGPS))
M Mark Ryan Penafiel Member Licensed User Longtime User Mar 25, 2020 #16 Yes i saw the raduis in the documentation, i also saw country but could not find an example. I guess raduis will do for now.thanks for the replies
Yes i saw the raduis in the documentation, i also saw country but could not find an example. I guess raduis will do for now.thanks for the replies
S SteevMac New Member Licensed User Longtime User Apr 28, 2021 #17 Just a small point but I think that the code in the B4A sample code for the Web call to the Places API has a typo.. It says.. j.Download2("https://maps.googleapis.com/maps/api/place/details/json", _ Array As String("key", GoogleApiKey, "placeid", Place.Id)) but the kay value for the place id should be place_id (ie with an underscore)
Just a small point but I think that the code in the B4A sample code for the Web call to the Places API has a typo.. It says.. j.Download2("https://maps.googleapis.com/maps/api/place/details/json", _ Array As String("key", GoogleApiKey, "placeid", Place.Id)) but the kay value for the place id should be place_id (ie with an underscore)