0

If I look at the documentation of setRegionCode("se") I see this javadoc documentation:

To restrict results to a region, use region_code_restriction.

I would like to restrict the results to "sweden"

But can't find on AutocompletePlacesRequest a setRegionCodeRestriction("se") method?

        AutocompletePlacesRequest.newBuilder()
            .setInput(placeInput)
            .addIncludedPrimaryTypes("geocode")
            .setIncludeQueryPredictions(true)
            .setRegionCode("se")
            .setLanguageCode("en")
            .setSessionToken("12345")
            .build();

Is the documentation on the java autocomplete client misleading?

3
  • You can try combining setRegionCode("se") with a geographic bounding box. .setLocationRestriction( LatLngBounds.newBuilder() .setSouthwest(LatLng.newBuilder().setLatitude(55.0).setLongitude(11.0).build()) .setNortheast(LatLng.newBuilder().setLatitude(69.0).setLongitude(24.0).build()) .build() ) Filter responses post-fetch to enforce "Sweden-only" results by looking at the returned address components. Commented Apr 16 at 16:19
  • Not sure if LatLngBounds builder is available in 'com.google.maps:google-maps-places:0.31.0' ? I can't find it Commented Apr 16 at 16:32
  • I allready have the latest com.google.maps:google-maps-places:0.31.0. Is this a library from Android? I am just on java 17 Commented Apr 16 at 17:02

0

Your Answer

By clicking β€œPost Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.