Place picker on Google Maps for Flutter

Overview

Google Maps Place Picker

A Flutter plugin which provides 'Picking Place' using Google Maps widget.

The project relies on below packages.

Map using Flutter's official google_maps_flutter
Fetching current location using Baseflow's geolocator
Place and Geocoding API using hadrienlejard's google_maps_webservice
Builder using kevmoo's tuple

Preview

Support

If the package was useful or saved your time, please do not hesitate to buy me a cup of coffee! ;)
The more caffeine I get, the more useful projects I can make in the future.

Buy Me A Coffee

Getting Started

  • Get an API key at https://cloud.google.com/maps-platform/.

  • Enable Google Map SDK for each platform.

    • Go to Google Developers Console.
    • Choose the project that you want to enable Google Maps on.
    • Select the navigation menu and then select "Google Maps".
    • Select "APIs" under the Google Maps menu.
    • To enable Google Maps for Android, select "Maps SDK for Android" in the "Additional APIs" section, then select "ENABLE".
    • To enable Google Maps for iOS, select "Maps SDK for iOS" in the "Additional APIs" section, then select "ENABLE".
    • Make sure the APIs you enabled are under the "Enabled APIs" section.
  • You can also find detailed steps to get started with Google Maps Platform here.

Android

Specify your API key in the application manifest android/app/src/main/AndroidManifest.xml:

<manifest ...
  <application ...
    <meta-data android:name="com.google.android.geo.API_KEY"
               android:value="YOUR KEY HERE"/>

NOTE: As of version 3.0.0 the geolocator plugin switched to the AndroidX version of the Android Support Libraries. This means you need to make sure your Android project is also upgraded to support AndroidX. Detailed instructions can be found here.

The TL;DR version is:

  1. Add the following to your "gradle.properties" file:
android.useAndroidX=true
android.enableJetifier=true
  1. Make sure you set the compileSdkVersion in your "android/app/build.gradle" file to 28:
android {
 compileSdkVersion 28

 ...
}
  1. Make sure you replace all the android. dependencies to their AndroidX counterparts (a full list can be found here: https://developer.android.com/jetpack/androidx/migrate).

iOS

Specify your API key in the application delegate ios/Runner/AppDelegate.m:

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "GoogleMaps/GoogleMaps.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application
    didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
  [GMSServices provideAPIKey:@"YOUR KEY HERE"];
  [GeneratedPluginRegistrant registerWithRegistry:self];
  return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end

Or in your swift code, specify your API key in the application delegate ios/Runner/AppDelegate.swift:

import UIKit
import Flutter
import GoogleMaps

@UIApplicationMain
@objc class AppDelegate: FlutterAppDelegate {
  override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?
  ) -> Bool {
    GMSServices.provideAPIKey("YOUR KEY HERE")
    GeneratedPluginRegistrant.register(with: self)
    return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }
}

On iOS you'll need to add the following entries to your Info.plist file (located under ios/Runner) in order to access the device's location.

Simply open your Info.plist file and add the following:

<key>NSLocationWhenInUseUsageDescription</key>
<string>This app needs access to location when open.</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>This app needs access to location when in the background.</string>
<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>This app needs access to location when open and in the background.</string>

In addition, you need to add the Background Modes capability to your XCode project (Project > Signing and Capabilties > "+ Capability" button) and select Location Updates.g>This app needs access to location when open and in the background.

Opt-in to the embedded views preview by adding a boolean property to the app's Info.plist file with the key io.flutter.embedded_views_preview and the value YES.

<key>io.flutter.embedded_views_preview</key>
<true/>

Usage

Basic usage

You can use PlacePicker by pushing to a new page using Navigator, OR put as a child of any widget.
When the user picks a place on the map, it will return result to 'onPlacePicked' with PickResult type. Alternatively, you can build your own way with 'selectedPlaceWidgetBuilder' and fetch result from it (See the instruction below).

Navigator.push(
      context,
      MaterialPageRoute(
        builder: (context) => PlacePicker(
          apiKey: APIKeys.apiKey,   // Put YOUR OWN KEY here.
          onPlacePicked: (result) { 
            print(result.address); 
            Navigator.of(context).pop();
          },
          initialPosition: HomePage.kInitialPosition,
          useCurrentLocation: true,
        ),
      ),
    );

PickResult

Parameter Type Description
placeId String A textual identifier that uniquely identifies a place. To retrieve information about the place, pass this identifier in the placeId field of a Places API request. See PlaceId for more information.
geometry Geometry Contains geometry information about the result, generally including the location (geocode) of the place and (optionally) the viewport identifying its general area of coverage.
formattedAddress String A string containing the human-readable address of this place. Often this address is equivalent to the "postal address".
types List<String> Contains an array of feature types describing the given result. See the list of supported types. XML responses include multiple elements if more than one type is assigned to the result.
addressComponents List<AddressComponent> An array containing the separate components applicable to this address.

** Below results will be fetched only when using auto-complete search or usePlaceDetailSearch is set to true when searching by dragging the map.

PickResult (Optional)

Parameter Type Description
adrAddress String A representation of the place's address in the adr microformat
formattedPhoneNumber String Contains the place's phone number in its local format
id String ? (Not documented at Google - see more info below)
reference String ? (Not documented at Google - see more info below)
icon String The URL of a suggested icon which may be displayed to the user when indicating this result on a map.
name String Human-readable name for the returned result
openingHours OpeningHoursDetail Opening hour information
photos List<Photo> Array of photo objects, each containing a reference to an image
internationalPhoneNumber String The place's phone number in international format
priceLevel PriceLevel The price level of the place, on a scale of 0 to 4. The exact amount indicated by a specific value will vary from region to region.
rating num The place's rating, from 1.0 to 5.0, based on aggregated user reviews.
scope String
url String The URL of the official Google page for this place.
vicinity String Lists a simplified address for the place, including the street name, street number, and locality, but not the province/state, postal code, or country
utcOffset num The number of minutes this place’s current timezone is offset from UTC
website String The authoritative website for this place
reviews List<Review> JSON array of up to five reviews

More info about results at Google document.

PlacePicker

Parameter Type Description
apiKey String (Required) Your google map API Key
onPlacePicked Callback(PickResult) Invoked when user picks the place and selects to use it. This will not be called if you manually build 'selectedPlaceWidgetBuilder' as you will override default 'Select here' button.
initialPosition LatLng (Required) Initial center position of google map when it is created. If useCurrentLocation is set to true, it will try to get device's current location first using GeoLocator.
useCurrentLocation bool Whether to use device's current location for initial center position. This will be used instead of initial position when it is set to true AND user ALLOW to collect their location. If DENIED, initialPosition will be used.
desiredLocationAccuracy LocationAccuracy Accuracy of fetching current location. Defaults to 'high'.
hintText String Hint text of search bar
searchingText String A text which appears when searching is performing. Default to 'Searching...'
proxyBaseUrl String Used for API calling on google maps. In case of using a proxy the baseUrl can be set. The apiKey is not required in case the proxy sets it.
httpClient Client Used for API calling on google maps. In case of using a proxy url that requires authentication or custom configuration.
autoCompleteDebounceInMilliseconds int Debounce timer for auto complete input. Default to 500
cameraMoveDebounceInMilliseconds int Debounce timer for searching place with camera(map) dragging. Defaults to 750
intialMapType MapType MapTypes of google map. Defaults to normal.
enableMapTypeButton bool Whether to display MapType change button on the map
enableMyLocationButton bool Whether to display my location button on the map
usePinPointingSearch bool Defaults to true. This will allow user to drag map and get a place info where the pin is pointing.
usePlaceDetailSearch bool Defaults to false. Setting this to true will get detailed result from searching by dragging the map, but will use +1 request on Place Detail API.
onAutoCompleteFailed Callback(String) Invoked when auto complete search is failed
onGeocodingSearchFailed Callback(String) Invoked when searching place by dragging the map failed
onMapCreated MapCreatedCallback Returens google map controller when created
selectedPlaceWidgetBuilder WidgetBuilder Specified on below section
pinBuilder WidgetBuilder Specified on below section
autocompleteOffset num The position, in the input term, of the last character that the service uses to match predictions
autocompleteRadius num The distance (in meters) within which to return place results
autocompleteLanguage String The language code, indicating in which language the results should be returned, if possible.
autocompleteComponents List<Components> A grouping of places to which you would like to restrict your results. Currently, you can use components to filter by up to 5 countries.
autocompleteTypes List<String> The types of place results to return. See Place Types.
strictbounds bool Returns only those places that are strictly within the region defined by location and radius.
region String region — The region code, specified as a ccTLD (country code top-level domain) two-character value. Most ccTLD codes are identical to ISO 3166-1 codes, with some exceptions. This parameter will only influence, not fully restrict, search results. If more relevant results exist outside of the specified region, they may be included. When this parameter is used, the country name is omitted from the resulting formatted_address for results in the specified region.
selectInitialPosition bool Whether to display selected place on initial map load. Defaults to false.
resizeToAvoidBottomInset bool Refer to Scaffold's resizeToAvoidBottomInset property.
initialSearchString String Sets initial search string for auto complete search
searchForInitialValue bool Wether to automatically search for initial value on start
forceAndroidLocationManager bool On Android devices you can set this to true to force the geolocator plugin to use the 'LocationManager' to determine the position instead of the 'FusedLocationProviderClient'. On iOS this is ignored.
myLocationButtonCooldown int Cooldown time in seconds for the 'myLocationButton'. Defaults to 10 seconds.
forceSearchOnZoomChanged bool Wether to allow place search even when the zoom has changed. Defaults to false.
automaticallyImplyAppBarLeading bool By default, there is a back button on the top. Setting false will remove the back button.
autocompleteOnTrailingWhitespace bool Whether to allow autocomplete to run even on whitespace at the end of the search. Defaults to false. Issue ref #54.

More info about autocomplete search at Google document.

Customizing picked place visualisation

By default, when a user picks a place by using auto complete search or dragging the map, we display the information at the bottom of the screen (FloatingCard).

However, if you don't like this UI/UX, simply override the builder using 'selectedPlaceWidgetBuilder'. FlocatingCard widget can be reused which is floating around the screen or build an entirely new widget as you want. It is stacked with the map, so you might want to use the Positioned widget.

Note that using this customization WILL NOT INVOKE [onPlacePicked] callback as it will override default 'Select here' button on floating card

...
PlacePicker(apiKey: APIKeys.apiKey,
            ...
            selectedPlaceWidgetBuilder: (_, selectedPlace, state, isSearchBarFocused) {
              return isSearchBarFocused
                  ? Container()
                  // Use FloatingCard or just create your own Widget.
                  : FloatingCard(
                      bottomPosition: 0.0,    // MediaQuery.of(context) will cause rebuild. See MediaQuery document for the information.
                      leftPosition: 0.0,
                      rightPosition: 0.0,
                      width: 500,
                      borderRadius: BorderRadius.circular(12.0),
                      child: state == SearchingState.Searching ? 
                                      Center(child: CircularProgressIndicator()) : 
                                      RaisedButton(onPressed: () { print("do something with [selectedPlace] data"); },),
                   );
            },
            ...
          ),
...
Parameters Type Description
context BuildContext Flutter's build context value
selectedPlace PickResult Result data of user selected place
state SearchingState State of searching action. (Idle, Searching)
isSearchBarFocused bool Whether the search bar is currently focused so the keyboard is shown

Customizing Pin

By default, Pin icon is provided with very simple picking animation when moving around.
However, you can also create your own pin widget using 'pinBuilder'

PlacePicker(apiKey: APIKeys.apiKey,
            ...
            pinBuilder: (context, state) {
                  if (state == PinState.Idle) {
                    return Icon(Icons.favorite_border);
                  } else {
                    return AnimatedIcon(.....);
                  }
                },
            ...                        
          ),
...
Parameters Type Description
context BuildContext Flutter's build context value
state PinState State of pin. (Preparing; When map loading, Idle, Dragging)

Changing Colours of default FloatingCard

While you can build your own prediction tile, you still can change the style of default tile using themeData as below:

// Light Theme
final ThemeData lightTheme = ThemeData.light().copyWith(
  // Background color of the FloatingCard
  cardColor: Colors.white,
  buttonTheme: ButtonThemeData(
    // Select here's button color
    buttonColor: Colors.black,
    textTheme: ButtonTextTheme.primary,
  ),
);

// Dark Theme
final ThemeData darkTheme = ThemeData.dark().copyWith(
  // Background color of the FloatingCard
  cardColor: Colors.grey,
  buttonTheme: ButtonThemeData(
    // Select here's button color
    buttonColor: Colors.yellow,
    textTheme: ButtonTextTheme.primary,
  ),
);

Feature Requests and Issues

Please file feature requests and bugs at the issue tracker.

Other useful packages you might be insterested

Firebase Auth Simplify
Material design Speed Dial

Buy Me A Coffee

Comments
  • useCurrentLocation but it does not pop the address on default

    useCurrentLocation but it does not pop the address on default

    Hi, I have tried to move the map to different location from the current pin location. Then at time I press the current location icon it goes fast and stick there. At time I got press few times before it returns there? Is there any settings to control it?

    question 
    opened by newbieflutter 15
  • Place Picker takes 11 seconds to load on IOS

    Place Picker takes 11 seconds to load on IOS

    Describe the bug When I use the Place Picker on an IOS 8 device it takes 11 seconds to load google maps. When I do this on the Android simulator it takes a few seconds for it to load.

    To Reproduce Loads the feature on an IOS device.

    Expected behavior I expected it to behave similar to the Android simulator

    Screenshots If applicable, add screenshots to help explain your problem.

    Flutter Doctor -v [✓] Flutter (Channel stable, v1.17.1, on Mac OS X 10.15.3 19D76, locale en-CA) • Flutter version 1.17.1 at /Users/****/Development/flutter • Framework revision f7a6a7906b (3 weeks ago), 2020-05-12 18:39:00 -0700 • Engine revision 6bc433c6b6 • Dart version 2.8.2

    [!] Android toolchain - develop for Android devices (Android SDK version 29.0.3) • Android SDK at /Users/****/Library/Android/sdk • Platform android-29, build-tools 29.0.3 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211) ✗ Android license status unknown. Try re-installing or updating your Android SDK Manager. See https://developer.android.com/studio/#downloads or visit visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions.

    [✓] Xcode - develop for iOS and macOS (Xcode 11.4) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.4, Build version 11E146 • CocoaPods version 1.9.0

    [✓] Android Studio (version 3.6) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 44.0.2 • Dart plugin version 192.7761 • Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b4-5784211)

    [✓] VS Code (version 1.45.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.10.2

    [✓] Connected device (2 available) • AOSP on IA Emulator • emulator-5554 • android-x86 • Android 9 (API 28) (emulator) • iPhone • ios • iOS 13.4.1

    ! Doctor found issues in 1 category.

    question 
    opened by amirhabibz 12
  • Don't know what is this issue exactly

    Don't know what is this issue exactly

    The plugin google_api_availability doesn't have a main class defined in E:\flutter_installation\flutter.pub-cache\hosted\pub.dartlang.org\google_api_availability-2.0.4\android\src\main\java\com\baseflow\googleapiavailability\GoogleApiAvailabilityPlugin.java or E:\flutter_installation\flutter.pub-cache\hosted\pub.dartlang.org\google_api_availability-2.0.4\android\src\main\kotlin\com\baseflow\googleapiavailability\GoogleApiAvailabilityPlugin.kt. This is likely to due to an incorrect androidPackage: com.baseflow.googleapiavailability or mainClass entry in the plugin's pubspec.yaml. If you are the author of this plugin, fix the androidPackage entry or move the main class to any of locations used above. Otherwise, please contact the author of this plugin and consider using a different plugin in the meanwhile.

    opened by aTeamSolace 8
  • Getting the Name of a Place

    Getting the Name of a Place

    I'm enjoying the interface of this addon, I've gone through 4 other Google Place pickers and this one fits my needs better. I got it implemented in my project but ran into an issue getting all the data I was looking for. I can't seem to find the name of the selected place, which I thought would have been built in. I got the address, addressComponents and geo point, and checked all the returned results, but the name's not there. Hoping this is an easy one to put in for the next version.

    Another issue I was noticing is after I type a location then select from the list, I see the Select Here button for a moment, but when the keyboard goes away, so does the location that I just picked. I have to press Select Here quickly or it goes back to the spinning. I assume it's not just me and others see this same problem. Otherwise all's good, thanks for the work you put into this, good stuff..

    bug enhancement 
    opened by Skquark 8
  • Bug with Null safety with Flutter 2.0.1

    Bug with Null safety with Flutter 2.0.1

    Describe the bug Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't. prediction.placeId, Error: Method 'substring' cannot be called on 'String?' because it is potentially null. Try calling using ?. instead. Error: Method 'substring' cannot be called on 'String?' because it is potentially null. Try calling using ?. instead. Error: Property 'length' cannot be accessed on 'String?' because it is potentially null. Try accessing using ?. instead. Error: Method 'substring' cannot be called on 'String?' because it is potentially null. Try calling using ?. instead.

    To Reproduce Steps to reproduce the behavior: When you run the app you will get the errors above

    Expected behavior

    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.0.0-nullsafety.1/lib/src/place_picker.dart:320:18: Error: The argument type 'String?' can't be assigned to the parameter type 'String' because 'String?' is nullable and 'String' isn't.
          prediction.placeId,
                     ^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.0.0-nullsafety.1/lib/src/components/prediction_tile.dart:37:42: Error: Method 'substring' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
                text: prediction.description.substring(0, matchedSubString.offset as int?),
                                             ^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.0.0-nullsafety.1/lib/src/components/prediction_tile.dart:46:40: Error: Method 'substring' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
              text: prediction.description.substring(matchedSubString.offset as int, matchedSubString.offset + matchedSubString.length as int?),
                                           ^^^^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.0.0-nullsafety.1/lib/src/components/prediction_tile.dart:52:86: Error: Property 'length' cannot be accessed on 'String?' because it is potentially null.
    Try accessing using ?. instead.
          if (matchedSubString.offset + matchedSubString.length < prediction.description.length) {
                                                                                         ^^^^^^
    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.0.0-nullsafety.1/lib/src/components/prediction_tile.dart:55:42: Error: Method 'substring' cannot be called on 'String?' because it is potentially null.
    Try calling using ?. instead.
                text: prediction.description.substring(matchedSubString.offset + matchedSubString.length as int),
                                             ^^^^^^^^^
    

    Flutter Doctor -v Flutter 2.0.1 Stable Release

    opened by SmarterVision 7
  • Do not use Mutable Providers.

    Do not use Mutable Providers.

    If possible. create the map provider first, then the search provider. Using a mutable provider variable causes inconsistent and messy dependency flow.

    You could add a linter in your repository to know what to follow best practices. When I fork this repo and added a linter. a lot of red lines & dynamic types in the code which is a red flag to me. Thanks!

    opened by vinceramcesoliveros 6
  • Searching Function not working

    Searching Function not working

    Searching Function is not working . Searching for Location is neither showing Auto complete search bar nor Selecting Any location . It is just Loading the search indicator to infinte. Screenshots

    opened by Reet0709 6
  • how to show card on start

    how to show card on start

    i want to ask how can i show the card address when the user open map auto goes to current location but the card disappear
    2. how can i show error message if the user dose not enable his gps location ?

    duplicate question 
    opened by bilalhassanqadri 6
  • SearchingState stuck at 'Searching' after selecting a suggested place

    SearchingState stuck at 'Searching' after selecting a suggested place

    Describe the bug When selecting an option from the suggested dropdown list, the map animates to the selected location, but the SearchingState in the selectedPlaceWidgetBuilder remains stuck at 'SearchingState.Searching', even though a PickResult is returned. When moving the map to a different position it fixes itself.

    I am using the pre-release version 2.0.0-nullsafety.3

    A temp fix is to check if PickResult is not null in selectedPlaceWidgetBuilder, but then the effect of a loader when moving between places is not possible.

    To Reproduce Steps to reproduce the behavior:

    1. Search for any place
    2. Click on any suggestion
    3. Notice the SearchingState in selectedPlaceWidgetBuilder remains stuck at 'SearchingState.Searching'.

    Expected behavior The SearchingState in selectedPlaceWidgetBuilder should change to 'SearchingState.Idle' once the PickResult is returned.

    Flutter Doctor -v [✓] Flutter (Channel stable, 2.0.6, on Mac OS X 10.15.7 19H15 darwin-x64, locale en-ZA) • Flutter version 2.0.6 at /Users/wiansnyman/Development/flutter • Framework revision 1d9032c7e1 (5 weeks ago), 2021-04-29 17:37:58 -0700 • Engine revision 05e680e202 • Dart version 2.12.3

    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/wiansnyman/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted.

    [✓] Xcode - develop for iOS and macOS • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.1, Build version 12A7403 • CocoaPods version 1.10.1

    [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 48.1.2 • Dart plugin version 193.7361 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

    [✓] VS Code (version 1.56.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.22.0

    [✓] Connected device (2 available) • iPhone 11 (mobile) • A412F27A-EB0B-45CA-96B2-9FAC6FB7E655 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-1 (simulator) • Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.212

    • No issues found!

    opened by Wian-TMC 5
  • For iOS only, After Search and select place . Selected place doesn't display in

    For iOS only, After Search and select place . Selected place doesn't display in "select here" box.

    Describe the bug For iOS only, After Search and select place . Selected place doesn't display in "select here" box. It keep showing loading.

    To Reproduce Steps to reproduce the behavior:

    1. search location address
    2. select the one address in suggested placed
    3. Bottom select here box now showing selected search result. It keep showing loading. The issue is only for iOS.
    4. If we move map then it show the address.
    opened by manpreetpatil 5
  • On search, not all places are listed when strictbounds is enabled

    On search, not all places are listed when strictbounds is enabled

    On search, not all places are listed when 'strictbounds' is enabled

    Hi @fysoul17, first of all, thank you very much for creating this package. I am using this package to find a place from a specific region, but it doesn't work when the 'strictbounds' parameter is enabled.

    strictbounds disabled, valid results https://maps.googleapis.com/maps/api/place/autocomplete/json?input=brewsky&inputtype=textquery&region=in&key=YOUR_API_KEY

    strictbounds enabled, no results https://maps.googleapis.com/maps/api/place/autocomplete/json?input=brewsky&inputtype=textquery&region=in&key=YOUR_API_KEY&strictbounds=true

    Possible Solution I think this behavior is because of using /autocomplete API (via google_maps_webservice) instead of the /findplacefromtext API.

    This works, https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=brewsky&inputtype=textquery&region=in&key=YOUR_API_KEY&strictbounds=true

    I agree that this approach will cost (places * n) additional API requests since the place details need to be fetched using the /place/details API, https://maps.googleapis.com/maps/api/place/details/json?place_id=ChIJCbkJxBMVrjsRq0aAA3mwudg&key=YOUR_API_KEY

    Maybe this approach can be supported on opt-in and disabled by default. I don't know a better way of doing this, suggestions welcomed.

    Moreover, the dependency package google_maps_webservice doesn't support finding the places using /findplacefromtext API now. I would be able to submit a PR if this is the only solution.

    I haven't used Google maps API's a lot, please correct me if this doesn't make much sense. What do you think?

    question 
    opened by SelvarajKaruppusamy 5
  • The method 'RaisedButton' isn't defined for the class 'GoogleMapPlacePicker'.

    The method 'RaisedButton' isn't defined for the class 'GoogleMapPlacePicker'.

    ../../../../../flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.1.0-nullsafety.3/lib/src/google_map_place_picker.dart:339:11: Error: The method 'RaisedButton' isn't defined for the class 'GoogleMapPlacePicker'.

    • 'GoogleMapPlacePicker' is from 'package:google_maps_place_picker/src/google_map_place_picker.dart' ('../../../../../flutter/.pub-cache/hosted/pub.dartlang.org/google_maps_place_picker-2.1.0-nullsafety.3/lib/src/google_map_place_picker.dart'). Try correcting the name to the name of an existing method, or defining a method named 'RaisedButton'. RaisedButton( ^^^^^^^^^^^^

    it's the error I got can someone help?

    opened by CodeLifeITs 1
  • Expost Google Maps initialCameraPosition parameter

    Expost Google Maps initialCameraPosition parameter

    This parameter would allow specifiying initial Zoom, lat lng location etc

                initialCameraPosition: CameraPosition(
                  target: LatLng(
                    .latitude,
                    currentGeopoint?.longitude ??
                        longitude,
                  ),
                  zoom: 16,
                ),
    
    opened by giorgio79 0
  • getDefaultAdapter() in BluetoothAdapter has been deprecated

    getDefaultAdapter() in BluetoothAdapter has been deprecated

    Hi sir, I have tried lib this lib with my latest code and android debug version 31. It gives the the depeacted Bluetooth adapter error. Please update the permission handler you are using inside your lib. Because right now it gives me the error

    ermission_handler-6.1.3/android/src/main/java/com/baseflow/permissionhandler/ServiceManager.java:152: warning: [deprecation] getDefaultAdapter() in BluetoothAdapter has been deprecated final BluetoothAdapter bluetoothAdapter = BluetoothAdapter.getDefaultAdapter(); ^ error: warnings found and -Werror specified

    I think if you update the permission handler to 8.0.0 or above can solve this issue.

    opened by waleedkalyar 1
  • selectInitialPosition: true is not working

    selectInitialPosition: true is not working

    Describe the bug When i set the selectInitialPosition: true it should show the picked place in floating card when initialy open the map, but it doesn't show. I also added initialPosition: kInitialPosition and useCurrentLocation: true. The card is only shows when i searched a placed.

    To Reproduce Steps to reproduce the behavior:

    1. Go to '...'
    2. Click on '....'
    3. Scroll down to '....'
    4. See error

    Expected behavior A clear and concise description of what you expected to happen.

    Screenshots If applicable, add screenshots to help explain your problem. Screenshot_20220601-183933

    Flutter Doctor -v

    [✓] Flutter (Channel stable, 3.0.1, on macOS 12.4 21F79 darwin-arm (Rosetta), locale en-GB) • Flutter version 3.0.1 at /Users/daredevil/Developer/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision fb57da5f94 (13 days ago), 2022-05-19 15:50:29 -0700 • Engine revision caaafc5604 • Dart version 2.17.1 • DevTools version 2.12.2

    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0) • Android SDK at /Users/daredevil/Library/Android/sdk • Platform android-32, build-tools 32.0.0 • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840) • All Android licenses accepted.

    [✓] Xcode - develop for iOS and macOS (Xcode 13.3.1) • Xcode at /Applications/Xcode.app/Contents/Developer • CocoaPods version 1.11.3

    [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    [✓] Android Studio (version 2021.2) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

    [✓] VS Code (version 1.67.2) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.40.0

    [✓] Connected device (3 available) • SM G970F (mobile) • RF8M223FMRP • android-arm64 • Android 12 (API 31) • macOS (desktop) • macos • darwin-arm64 • macOS 12.4 21F79 darwin-arm (Rosetta) • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 ! Error: Alexis’s iPhone is not connected. Xcode will continue when Alexis’s iPhone is connected. (code -13)

    [✓] HTTP Host Availability • All required HTTP hosts are available

    • No issues found!

    Additional context This is the code i'm using

    Navigator.push(
                                context,
                                MaterialPageRoute(
                                  builder: (context) => PlacePicker(
                                    hintText: "Enter plot location",
                                    apiKey:
                                        "API KEY", // Put YOUR OWN KEY here.
    
                                    initialPosition: kInitialPosition,
                                    useCurrentLocation: true,
                                    selectInitialPosition: true,
                                    onPlacePicked: (result) {
                                      //print(result.address);
                                      _plotlocationController.text =
                                          result.formattedAddress!;
                                      print(result.formattedAddress);
                                      print(result.placeId);
                                      print(result.geometry!.location);
                                      print(result.types);
                                      Navigator.of(context).pop();
                                      setState(() {});
                                    },
                                  ),
                                ),
                              `);`
    
    opened by shanu95 0
Owner
Terry Kwon
Programmer / Open game dev streamer (Twitch, LiveEdu.tv, Youtube) / Gamer / Digital Nomad / Geek
Terry Kwon
Place picker on Google Maps for Flutter

Google Maps Place Picker A Flutter plugin which provides 'Picking Place' using Google Maps widget. The project relies on below packages. Map using Flu

Terry Kwon 178 Dec 16, 2022
A Flutter plugin which provides 'Picking Place' using Google Maps widget

Google Maps Places Picker Refractored This is a forked version of google_maps_place_picker package, with added custom styling and features.

Varun 5 Nov 13, 2022
Flutter Maps A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Salsabil Mohamed Hemada 1 Jul 15, 2022
Easy to use Animated Maps Markers with a detail card. Use it for a store or any place locator.

interactive_maps_marker for Flutter Easy to use Animated Maps Markers with detail card. Use it for store or any place locator. Demo Usage Add this pac

Atiq Samtia 95 Dec 28, 2022
A flutter plugin for Google Maps

IMPORTANT: This plugin is no longer under development Why? We initially built this plugin to fill an early gap in flutter. Since then, Google has made

AppTree Software, Inc 415 Dec 29, 2022
Flutter Google Maps Tutorial

Flutter Google Maps Tutorial YouTube Video Setup Get an API Key at https://cloud.google.com/maps-platform/ Enable Maps SDK for Android, Maps SDK for i

Marcus Ng 85 Nov 30, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Youhaan bootwala 1 Mar 18, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Varun CN 2 Apr 19, 2022
This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with simple smooth animations, making a nice UI and UX.

search_map_place This is a Flutter package that uses the Google Maps API to make a TextField that tries to autocomplete places as the user types, with

Lucas Bernardi 127 Oct 22, 2022
Easy Google Maps for Flutter

easy_google_maps Easy Google Maps for Flutter on Web and Mobile Getting Started Mobile Follow setup for Mobile Here Web Good to go! EasyGoogleMaps(

Rody Davis 69 Jul 19, 2022
A car rental flutter application using firebase and google maps API

A car sharing & rental app using Flutter, Firebase & Google Maps APIs ?? About the App ?? hopOn is flutter based application for car sharing and renta

Shivani Singh 97 Dec 30, 2022
Simple flutter app demonstrating usage of Google Maps

flutter_maps_example Get an API key at GoogleCloud. Enable Google Map SDK for ea

Tornike Gogberashvili 0 Nov 23, 2022
A Flutter plugin for integrating Google Maps in iOS, Android and Web applications

flutter_google_maps A Flutter plugin for integrating Google Maps in iOS, Android and Web applications. It is a wrapper of google_maps_flutter for Mobi

MarchDev Toolkit 86 Sep 26, 2022
A flutter plugin that's decodes encoded google poly line string into list of geo-coordinates suitable for showing route/polyline on maps

flutter_polyline_points A flutter plugin that decodes encoded google polyline string into list of geo-coordinates suitable for showing route/polyline

Adeyemo Adedamola 75 Oct 25, 2022
Flutter Google Maps My Track

mytracker We invite you to subscribe to the Alpha flutter code channel on Youtub

NELSON YUNGA 6 Oct 31, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Tsenda LAB 1 Mar 28, 2022
A Flutter app using Google Maps SDK & Directions API

Flutter Maps A Flutter app using Google Maps SDK & Directions API Plugins The plugins used in this project are: google_maps_flutter geolocator flutter

Dreamfullstacker 16 Dec 31, 2022
Flutter package to enable clustering of location markers on Google Maps using widgets specific to each location.

flutter_google_maps_widget_cluster_markers This widget implements a very specific adaptation of google_maps_cluster_manager, allowing different ,marke

Kek Tech 2 Jan 6, 2023
Aplications with google maps and geolocation

Aplications with google maps and geolocation

Richardson Tsavo 4 Jul 26, 2022