AdevintaSpain / Leku

:earth_africa: Map location picker component for Android. Based on Google Maps. An alternative to Google Place Picker.
https://adevintaspain.github.io/Leku/
Apache License 2.0
763 stars 170 forks source link

Search places not searching all over the world search zone not provided #289

Closed fouadkada closed 4 years ago

fouadkada commented 4 years ago

The documentation states the following:

Note: If you don't specify any search zone it will not search using any default search zone. It will search on all around the world.

I am starting LocationPickerActivity as follows:

Intent intent = new LocationPickerActivity.Builder().shouldReturnOkOnBackPressed()
                .withZipCodeHidden()
                .withSatelliteViewHidden()
                .withVoiceSearchHidden()
                .withGooglePlacesEnabled()
                .build(getActivity());

In my Manifest file I have the following:

 <meta-data
            android:name="com.google.android.geo.API_KEY"
            android:value="@string/google_maps_key" />

I also made sure to enable Google Places API in the google developer console.

However when the LocationPickerActivity starts and I search in the search box, I only get results in the USA & Canada because my device's locale is en_US.

What am I missing?

the library dependencies:

implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation("com.google.android.libraries.places:places-compat:1.0.0")
implementation("com.schibstedspain.android:leku:5.0.0") {
        exclude group: 'com.google.android.gms'
        exclude module: "play-services-places"
}
ferranpons commented 4 years ago

Hi @fouadkada , I'm afraid that if you're using an en_US locale it will use that locale because it's always using your device locale. That part of the documentation refers to that is only applicable when you are using the search zone rect option. If you want to search only on a zone you must use use the locale of the country where you are in your device or override it with use these options:

.withSearchZone("es_ES")
.withSearchZone(SearchZoneRect(LatLng(26.525467, -18.910366), LatLng(43.906271, 5.394197)))
fouadkada commented 4 years ago

Hi @ferranpons

Thanks a lot. it makes sense now.

Is the search places API included in this project? like for example search for businesses, points of interests, street names? I understand that this feature might result in additional charges from google APIs.

Thanks

ferranpons commented 4 years ago

@fouadkada you're welcome!

Google Places API is included but is optional, and sure it will result in additional charges from Google. You could activate it with:

.withGooglePlacesEnabled()

😉

fouadkada commented 4 years ago

@ferranpons Thanks again 👍