bazrafkan / google_place Goto Github PK
View Code? Open in Web Editor NEWA new Flutter package for handle google place api
License: MIT License
A new Flutter package for handle google place api
License: MIT License
Hi!
I saw this plugin was able on the web and trying it, it returns an error regarding CORS.
Any idea?
Access to XMLHttpRequest at 'https://maps.googleapis.com/maps/api/place/autocomplete/json?input=auerstras&key={MY_KEY}' from origin 'http://localhost:37277' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
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);
The default limit seems 5, how can we change it?
Thanks.
in flutter web, all requests are retuning null value.
I had referred your code and it works but little confusion is that when we search a place the listtile in the place can't be choosen. How to solve this?
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?
helloo, is there a way to extract the city name from search results ?
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
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?
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.
Hi, thanks for the package. I do not want to enable web credentials on my google cloud - and I can't get my platform-specific credentials to work.
Is there a limitation like that?
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.
This is failing to latest flutter 2.0.0
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)
Hi currently we got Uint8List when get photos, is there a way to get photo url instead?
thanks a lot
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,
);
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?
Hi, how can we get details in each 'types' in the address_components of the 'detailsResult' ?
It looks like this package is pure Dart and does not depend on Flutter, but it is listed as a dependency. Any interest in removing this dependency?
https://github.com/bazrafkan/google_place/search?q=package%3Aflutter
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
Unhandled Exception: Failed assertion: boolean expression must not be null
#0 new Locationbias (package:google_place/src/models/locationbias.dart:41:27)
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'.
adoi, at least override toString method la
var res = await googlePlace.autocomplete.get(query, types: 'cities');
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?
Great package. Easy to customise.
Can the predictions also include LatLng?
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]]
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
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?
I want search autocomplete work only a country specific not all over world!
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?
I am having trouble with proxyUrl, even with the demo of proxyUrl: 'cors-anywhere.herokuapp.com') or cors.bridged.cc (from https://github.com/Rob--W/cors-anywhere/issues/301#issuecomment-870990778). Any help would be appreciated.
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
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!`
Having checked on Google Maps that there is weekdayText available, I cannot get the data openingHours.weekdayText. Any ideas?
Please remove Web support from pub.dev
You updated the plugin to null-safety, but didn't update the example.
Places search and the overall package does not work on the web
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.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.