google_maps_place_search_advance
Custom Google search places autocomplete widget with landmark images and distance calculation.
π Get started
google_maps_place_search_advance provides programmatic access to Google's database for the place autocomplete search and also their landmark images, as well as distance with respect to the device's current place.
π‘ Features
Help your customers explore where they are and whatβs around them:
- Place Autocomplete automatically fills in the name and/or address of a place as users type.
- Place Geolocator gives the distance with respect to current position.
- Place Photos returns high-quality images of a place.
π Installation
Add dependency
You can use the command to add google_maps_place_search_advance as a dependency with the latest stable version:
$ dart pub add google_maps_place_search_advance
Or you can manually add google_maps_place_search_advance into the dependencies section in your pubspec.yaml:
dependencies:
google_maps_place_search_advance: ^replace-with-latest-version
Add image for the icon to appear it is required in the package to work.
flutter:
# To add assets to your package, add an assets section, like this:
assets:
- assets/search.png
The latest version is: The latest version including pre-releases is:
Before you upgrade: Breaking changes might happen in major and minor versions of packages.
See the Migration Guide
for the complete breaking changes list.
Super simple to use
import 'package:google_maps_place_search_advance/google_maps_place_search_advance.dart';
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return SafeArea(
child: Scaffold(
body: Container(
child: SingleChildScrollView(
child: GooglePlaceSearchAdvance(
googleMapsApiKey: "GOOGLE_MAPS_API_KEY",
country: "fr",
iconImagePath: "assets/search.png",
mapimagePath: "assets/not_image_place.png",
onLocationSelected: (double lat, double lng, String address, String imageURL){
print("Coordinates are $lat,$lng");
print("Address is : $address");
print("Image URL is: $imageURL");
},
),
),
),
),
);
}
}
π Generate App key
- Go to the Google Maps Platform > Credentials page.
- On the Credentials page, click Create credentials > API key. The API key created dialog displays your newly created API key.
- Click Close.The new API key is listed on the Credentials page under API keys.(Remember to restrict the API key before using it in production.)