Advertisement
Guest User

Dart AutoComplete Map

a guest
Jul 23rd, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Dart 1.48 KB | None | 0 0
  1. //ganti di action nya
  2.  onTap: () {
  3.     handlePressButton();
  4. },
  5.  
  6. //function autocomplete
  7. Future<void> _handlePressButton() async {
  8.     try {
  9.       final center = await getUserLocation();
  10.       // GoogleMapsPlaces _places = GoogleMapsPlaces(apiKey: kGoogleApiKey);
  11.       Prediction p = await PlacesAutocomplete.show(
  12.           context: context,
  13.           strictbounds: center == null ? false : true,
  14.           apiKey: kGoogleApiKey,
  15.           onError: onError,
  16.           mode: Mode.overlay,
  17.           language: "id",
  18.           location: center == null
  19.               ? null
  20.               : Location(center.latitude, center.longitude),
  21.           radius: center == null ? null : 10000000);//ini tergantung sejauh mana pencariannya
  22.  
  23.  
  24.       PlacesDetailsResponse place =
  25.           await _places.getDetailsByPlaceId(p.placeId);
  26.       // print("${center.latitude}, ${center.longitude}");
  27.       // print(place.result.name);
  28.       // setState(() {
  29.       //   startLocation = TextEditingController(text: place.result.name);
  30.       //   lat = TextEditingController(
  31.       //       text: place.result.geometry.location.lat.toString());
  32.       //   long = TextEditingController(
  33.       //       text: place.result.geometry.location.lng.toString());
  34.       //   myLat = TextEditingController(text: center.latitude.toString());
  35.       //   myLong = TextEditingController(text: center.longitude.toString());
  36.       // });
  37.       // showDetailPlace(p.placeId);
  38.     } catch (e) {
  39.       return;
  40.     }
  41.   }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement