fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
222 stars 357 forks source link

an example of how to use autocompleteComponents #111

Closed Xoshbin closed 3 years ago

Xoshbin commented 3 years ago

Hi, Can anyone please give an example of how to use autocompleteComponents. Thank you

PlacePicker(
      autocompleteComponents: [],

I want to restrict the placePicker to an area or a city if possible?!

fysoul17 commented 3 years ago

https://developers.google.com/maps/documentation/places/web-service/autocomplete

zopagaduanjr commented 2 years ago

Component class isn't automatically detected by my Android Studio, The suggested quick fix presented to me was to create your own Component Class.

Here's an example of autocompleteComponents by importing 'package:google_maps_webservice/places.dart'

import 'package:google_maps_webservice/places.dart' as google_maps_api;

PlacePicker(
    apiKey: APIKeys.apiKey,   // Put YOUR OWN KEY here.
    autocompleteComponents: [
        google_maps_api.Component("country", "fr") //restrict search results to France
    ],
    onPlacePicked: (result) { 
        print(result.address); 
        Navigator.of(context).pop();
    },
    initialPosition: HomePage.kInitialPosition,
        useCurrentLocation: true,
    ),

Component Class documentation.