GithubHelp home page GithubHelp logo

bazrafkan / google_place Goto Github PK

View Code? Open in Web Editor NEW
83.0 83.0 119.0 660 KB

A new Flutter package for handle google place api

License: MIT License

Dart 99.53% Kotlin 0.10% Swift 0.33% Objective-C 0.03%

google_place's Introduction

Hi there πŸ‘‹

  • 🌱 I'm currently learning to live with bugs
  • πŸ‘― I'm looking to collaborate on cool company
  • πŸ€” I'm looking for help with data science
  • πŸ’¬ Ask me about flutter
  • πŸ“« How to reach me: [email protected]

Mondora

google_place's People

Contributors

acoutts avatar allanwolski avatar bazrafkan avatar desync-o-tron avatar diegoarredondo avatar ema987 avatar kuroshmondora avatar sachin-dahal avatar tusharm avatar vitor-bukovitz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

google_place's Issues

FormatException while passing proxy url

Hi ,

I am passing yacdn.org/proxy as a proxy url to google_place. But I am getting below FormatException error when I run the app.

FormatException: Invalid character (at character 10) yacdn.org/proxy
                                                              ^        

No other proxy url with subpath is working. How do I fix it?

getNearBySearch cannot return results ranked by distance

Seems that I am unable to complete a nearby search ranked by distance.

The radius parameter is required leading to an Invalid request when a rankBy parameter is used.

NearBySearchResponse result = await googlePlace.search.getNearBySearch(
    Location(lat: position.latitude, lng: position.longitude),
    searchRadius, //required
    type: searchType,
    opennow: false,
    keyword: searchKeywords,
    rankby: RankBy.Distance, //can only be used if a radius is not specified,
);


AutocompletePrediction.fromJson throws NoSuchMethodError: The method 'map' was called on null.

Rare error seen on iOS production app when calling place.autocomplete.get(...):

NoSuchMethodError: NoSuchMethodError: The method 'map' was called on null.
Receiver: null
Tried calling: map<MainTextMatchedSubstring>(Closure: (dynamic) => MainTextMatchedSubstring)
  File "object_patch.dart", line 38, in Object.noSuchMethod
  File "object_patch.dart", line 85, in _objectNoSuchMethod
  File "structured_formatting.dart", line 22, in new StructuredFormatting.fromJson
  File "autocomplete_prediction.dart", line 65, in new AutocompletePrediction.fromJson
  File "autocomplete_response.dart", line 18, in new AutocompleteResponse.fromJson.<fn>
  File "iterable.dart", line 413, in MappedListIterable.elementAt
  File "iterable.dart", line 342, in ListIterator.moveNext
  File "growable_array.dart", line 206, in new _GrowableList._ofEfficientLengthIterable
  File "growable_array.dart", line 153, in new _GrowableList.of
  File "array_patch.dart", line 51, in new List.of
  File "set.dart", line 118, in SetMixin.toList
  File "autocomplete_response.dart", line 19, in new AutocompleteResponse.fromJson
  File "autocomplete_response.dart", line 26, in AutocompleteResponse.parseAutocompleteResult
  File "autocomplete.dart", line 110, in Autocomplete.get

JSON Output?

Hi, there are a possibility to get json output after select a prediction? I'm using autocomplete function. I'm trying to serialize AutocompletePrediction object without result. I neet json output to send it in http request

Flutter Web - Can't google place autocomplete to work unless using proxy url.

Has anybody got the google place working without using the proxy url?

Right now we are using 'cors-anywhere.herokuapp.com' as the proxy url and works with limitations, but in the long run we just do not want to use one.

Is there something that I am not understanding about the web that requires a proxy url?

Android embedding v2.

Dear bazrafkan,

Are you willing to look at this? I am new and not sure if I am looking at the latest version though.

flutter build apk
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Warning
──────────────────────────────────────────────────────────────────────────────
Your Flutter application is created using an older version of the Android
embedding. It is being deprecated in favor of Android embedding v2. Follow the
steps at

https://flutter.dev/go/android-project-migration

to migrate your project. You may also pass the --ignore-deprecation flag to
ignore this check and continue with the deprecated v1 embedding. However,
the v1 Android embedding will be removed in future versions of Flutter.
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
The detected reason was:

/Users/jorgenunes/2022-dev/google_place/example/android/app/src/main/AndroidManifest.xml uses
android:name="io.flutter.app.FlutterApplication"
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━

Build failed due to use of deprecated Android v1 embedding.

`% flutter doctor -v
[βœ“] Flutter (Channel stable, 3.3.0, on macOS 12.4 21F79 darwin-arm, locale pt-PT)
β€’ Flutter version 3.3.0 on channel stable at /Users/jorgenunes/flutter
β€’ Upstream repository https://github.com/flutter/flutter.git
β€’ Framework revision ffccd96b62 (Γ  7 dias), 2022-08-29 17:28:57 -0700
β€’ Engine revision 5e9e0e0aa8
β€’ Dart version 2.18.0
β€’ DevTools version 2.15.0

[βœ“] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
β€’ Android SDK at /Users/jorgenunes/Library/Android/sdk
β€’ Platform android-33, build-tools 33.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.4.1)
β€’ Xcode at /Applications/Xcode.app/Contents/Developer
β€’ Build 13F100
β€’ 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.71.0)
β€’ VS Code at /Applications/Visual Studio Code.app/Contents
β€’ Flutter extension version 3.48.0

[βœ“] Connected device (2 available)
β€’ macOS (desktop) β€’ macos β€’ darwin-arm64 β€’ macOS 12.4 21F79 darwin-arm
β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 104.0.5112.101

[βœ“] HTTP Host Availability
β€’ All required HTTP hosts are available

β€’ No issues found!`

Need prefix for class name 'Component'

Problem:
There is conflict of google_places package with google_maps_webservice

The name 'Component' is defined in the libraries 'package:google_maps_webservice/src/core.dart (via package:google_maps_webservice/places.dart)' and 'package:google_place/src/models/component.dart (via package:google_place/google_place.dart)'.

Solution:
Try using 'as prefix' for one of the import directives, or hiding the name from all but one of the imports.dart(ambiguous_import)
'Component' isn't a function.

Try correcting the name to match an existing function, or define a method or function named 'Component'.dart(invocation_of_non_function)

Limit Search Results?

Hello, thank you for this awesome package. I want to limit search results for a specific country however I could not see an option for this. Do you have a reccommendation for me?

Remove 'dart:ui' dependency

Hi.

As of version 0.4.0 you can't use this library on the standard dart VM due to it depending on the dart:ui package.

Running code on on the standard dart VM (dart run <source.dart>) that uses this library gives you the following error:

../../../../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/google_place-0.4.0/lib/src/models/lat_lon.dart:1:8: Error: Not found: 'dart:ui'
import 'dart:ui';
       ^
../../../../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/google_place-0.4.0/lib/src/models/lat_lon.dart:32:23: Error: The method 'hashValues' isn't defined for the class 'LatLon'.
 - 'LatLon' is from 'package:google_place/src/models/lat_lon.dart' ('../../../../../sdk/flutter/.pub-cache/hosted/pub.dartlang.org/google_place-0.4.0/lib/src/models/lat_lon.dart').
Try correcting the name to the name of an existing method, or defining a method named 'hashValues'.
  int get hashCode => hashValues(latitude, longitude);

very wrong geometry details,

I had to use

Places.DetailsResponse detail = await googlePlace.details.get(placeId);
    double lat = detail.result.geometry.location.lat;
    double lng = detail.result.geometry.location.lng;

however, the information retrieved unfortunately were not correct.
plus I really wish you append the (components part to allow using country)

Update
sorry I was wrong on details, it was correct.

thank u

Impossible to sort getNearBySearch() by distance using rankby parameter

The documentation for getNearBySearch() states the following contradiction:

[radius] Required parameters - Defines the distance (in meters) within which to return place results. The maximum allowed radius is 50 000 meters. **Note that radius must not be included if rankby=distance (described under Optional parameters below) is **specified.**

[rankby] Optional parameters - Specifies the order in which results are listed. **Note that rankby must not be included if radius (described under Required parameters above) is specified.**

However, the radius parameter is a required parameter and non-nullable, so it's impossible to exclude it.

cors-anywhere proxy set-up

Hi there,

first of all, thank you very much for the package!

I have a problem setting up the proxy with cors-anywhere....
How should the proxy url with cors-anywhere be formated? At the moment the request is sent like this ->
https://powerful-gorge-XXXX.herokuapp.com/https://maps.googleapis.com/maps/...

and in flutter:
void initState() {
googlePlace = g.GooglePlace('XXX',
proxyUrl: 'https://powerful-gorge-XXX.herokuapp.com');
super.initState();
}

Thank you very much,
Benno

Places api not working in flutter web

My below implementation is working fine in flutter iOS. But when running the same code in flutter web, its not working.

var googlePlace = GooglePlace("MY-API-KEY", proxyUrl: 'cors-anywhere.herokuapp.com'); googlePlace.autocomplete .get(enteredAddress.value) .then((autocompleteResponse) { loading.value = false; predictionList.value = autocompleteResponse.predictions; }).onError((error, stackTrace) { CommonUIMethods.showSnackBar("Something went wrong. Please try again later."); });

in the web I am not getting any error. Execution does goes inside the then callback, But the autocompleteResponse object is null. Does the plugin works for flutter web or not?

Optional timeout

Thank you for the great package. It helps me a lotπŸ€—

I guess the timeout 1500 mil sec is too short for some cases, so it should be set by optional.
Is it fine for you @bazrafkan ? If so, I will make pr for this change.

Search as you type alternating between REQUEST_DENIED and results

When using material search API in flutter to trigger search-as-you-type in a naiive fashion I get results mixed in with request denied errors.

    final result =
        await _googlePlace.autocomplete.get(query, types: '(cities)');

    /// Request denied
    if (result.status == 'REQUEST_DENIED') {
      print('Google Places API – Request Denied');
    } else if (result.status == 'ZERO_RESULTS') {
      print('Google Places API - No results found');
    } else {
      print(result.status);
    }
flutter: [h, [ChIJgTWgBRs1rkwRpHpP5mHeDJc, ChIJk2tNWqFJrkwRLyiJao0SSbo, ChIJAYWNSLS4QIYROwVl894CDco, ChIJofaJZoZSrkwRLY4oKAw6V4o, ChIJpVER8hFT5okRmVl96ahKjsw]]
flutter: [he, [ChIJgTWgBRs1rkwRpHpP5mHeDJc, ChIJk2tNWqFJrkwRLyiJao0SSbo, ChIJAYWNSLS4QIYROwVl894CDco, ChIJofaJZoZSrkwRLY4oKAw6V4o, ChIJpVER8hFT5okRmVl96ahKjsw]]
flutter: Google Places API – Request Denied
flutter: [he, []]
flutter: [hel, []]
flutter: [hell, []]
flutter: Google Places API – Request Denied
flutter: Google Places API – Request Denied
flutter: [hell, []]
flutter: [hello, []]
flutter: OK
flutter: [hello, [ChIJzfk9mlyLxkcR0deR5IaJFas, ChIJLWJrgnRsXIYRFXB0qq8GOF0, ChIJb-ZAjaIH4UcR-wJLDIpOc60, ChIJs8oMpZFu30cRbybbXERthVs, ChIJAReKwtIK4kcRHDn-t0AKvMg]]

Error on example code

i got this error while running the code from example.

'package:google_place/google_place.dart': Failed assertion: line 65 pos 12: 'apiKEY != null': is not true.

i have my api key in 'api_key'.

Option to request only specific fields from API

Is there a way to request fetching only certain fields instead of everything that Google Places API has to offer. The reason why this is important is that Google has different pricing options based on what fields you are requesting. For example, Store open hours, Ratings are part of paid API, and fields like name, GPS coordinates are part of Free API. Your assistance is highly appreciated.

Return coordinates

Great package. Easy to customise.
Can the predictions also include LatLng?

Not return the Lat Long.

void autoCompleteSearch(String value) async { var result = await googlePlace.autocomplete.get(value); if (result != null && result.predictions != null && mounted) { setState(() { predictions = result.predictions; }); } }

We have implemented the above code but "predictions" only return the below parameter.

AutocompletePrediction({ this.description, this.distanceMeters, this.id, this.matchedSubstrings, this.placeId, this.reference, this.structuredFormatting, this.terms, this.types, });

So how can I get the latitude and longitude?

Locationbias error: Failed assertion: line 42 pos 14: 'point != null && circular != null && rectangular != null': is not true.

Setting a circular Locationbias for getFindPlace() results in the following failed assertion:
Failed assertion: line 42 pos 14: 'point != null && circular != null && rectangular != null': is not true.

  Locationbias({this.ipbias, this.point, this.circular, this.rectangular}) {
    if (ipbias != null && ipbias!) {
      assert(point == null);
      assert(circular == null);
      assert(rectangular == null);
    }
    if (point != null) {
      assert(ipbias == null);
      assert(circular == null);
      assert(rectangular == null);
    }
    if (circular != null) {
      assert(ipbias == null);
      assert(point == null);
      assert(rectangular == null);
    }
    if (rectangular != null) {
      assert(ipbias == null);
      assert(point == null);
      assert(circular == null);
    }
    if (ipbias == null || ipbias!)
      assert(point != null && circular != null && rectangular != null);
  }

Line 42 states if ipbias is null, then point, circular, and rectangular should all be non-null. Is this intentional, or were those supposed to be logical OR conditions?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.