2

I’m using flutter_google_places_hoc081098 (or the official Android Places SDK) to autocomplete addresses in my Flutter app. Despite explicitly setting country filters or lat/lng bias for the United States, I keep getting results for Canadian locations. I’m physically located in the US (or so I believe), but the suggestions are still biased toward Canada What I’ve Tried Removing all code restrictions

Omitted components: [Component(Component.country, "us")], or set setCountries(listOf("US")) to see if that helps.

Same result: still seeing Canadian suggestions.

Forcing a US location + radius

Passed location: Location(lat: 40.7128, lng: -74.0060) (New York) and radius: 80000, plus strictbounds: true.

In theory, that should show addresses only around NYC.

Still mostly local Canadian results unless I type a very specific query like β€œNew York, NY, USA.”

Checking the device’s or emulator’s location

Set the Android emulator location to Florida or NYC in Extended Controls β†’ Location.

Verified the lat/lng is actually in the US.

No change in suggestions.

Confirming IP location

Visited iplocation.net to verify my IP geolocates in the US.

Still seeing Canadian addresses in the Places overlay.

Tried a VPN with a US endpoint; no consistent improvement.

Ensuring the old β€œPlaces API” is enabled

Billing is on, β€œPlaces API (New)” is enabled, also enabled the old β€œPlaces API” in Google Cloud.

Key restrictions are correct (app package name, SHA-1).

Key and billing are definitely working (no more REQUEST_DENIED unless I restrict the key incorrectly).

Typing a distinct US query

If I type β€œNew Y” or β€œLos A,” I sometimes still get local β€œNew York Style Pizza” or β€œLos Amigos” near me.

Must type β€œNew York, NY, USA” fully to see the city.

This is better, but still not the auto-suggestions I want for US addresses by default.

this is my code to autocomplelocation: import 'package:flutter/material.dart'; import 'package:flutter_google_places_hoc081098/flutter_google_places_hoc081098.dart'; import 'package:google_maps_webservice/places.dart';

const kGoogleApiKey = "GOOGLE API KEY";

class LocationAutocompleteField extends StatelessWidget { final Function(String) onLocationSelected;

const LocationAutocompleteField({Key? key, required this.onLocationSelected}) : super(key: key);

@override Widget build(BuildContext context) { return TextFormField( readOnly: true, decoration: InputDecoration( hintText: "Enter your address", border: OutlineInputBorder(borderRadius: BorderRadius.circular(12)), prefixIcon: Icon(Icons.location_on), ), onTap: () async { Prediction? prediction = await PlacesAutocomplete.show( context: context, apiKey: kGoogleApiKey, mode: Mode.overlay, language: "en", components: [Component(Component.country, "us")],

      // Change "ca" to "us" for US places or remove this line to not restrict by country.
    );

    if (prediction != null && prediction.description != null) {
      onLocationSelected(prediction.description!);
    }
  },
);

} }

1
  • 1
    The issue seems to reside in either the package flutter_google_places_hoc081098 or google_maps_webservice used in the sample code. With that, we suggest raising this issue in their respective repositories. You may use these links to report the issue: flutter_google_places_hoc081098 or google_maps_webservice This issue has been answered in the Google Public Issue Tracker, refer to this link. Commented May 12 at 1:51

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.