lejard-h / google_maps_webservice

BSD 3-Clause "New" or "Revised" License
168 stars 220 forks source link

How to Search for Addresses using Postal Codes #73

Open samueladekunle opened 4 years ago

samueladekunle commented 4 years ago

I am trying to get a list of addresses using postal codes.

This is a snippet of code:

import 'package:google_maps_webservice/places.dart';

final _places = GoogleMapsPlaces(apiKey: '<API-Key>');

void main() async {
  // This is a valid British postal code.
  final postalCode = 'WC2N 5DU';

  final response = await _places.autocomplete(
    postalCode,
    components: [
      Component(Component.postalCode, postalCode),
      Component(Component.country, 'UK'),
    ],
  );

  if (response.isOkay) {
    for (Prediction prediction in response.predictions) {
      print(prediction.description);
    }
  } else {
    print(response.status);
  }
}

I am getting an INVALID_REQUEST status.

lejard-h commented 3 years ago

Hello @samueladekunle

Sorry for late response but are you still having the issue ?