fysoul17 / google_maps_place_picker

Place picker on Google Maps for Flutter
MIT License
224 stars 364 forks source link

Place Picker takes 11 seconds to load on IOS #43

Closed amirhabibz closed 4 years ago

amirhabibz commented 4 years ago

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.

fysoul17 commented 4 years ago

Hi, It is duplicated to #26 , but there weren't any further updates regarding it.

Can you share the code of PlacePicker widget settings? Also, would you mind testing on another device or iPhone simulator as it did not happen on my side, and so I am unsure what is causing to your case.

amirhabibz commented 4 years ago
void showPlacePicker() async {
       Navigator.push(
        context,
        MaterialPageRoute(
          builder: (context) => PlacePicker(
            apiKey: "************",
            useCurrentLocation: true,
            usePlaceDetailSearch: true,
            onPlacePicked: (result) {
              setState(() {
                selectedPlace = result;
                locationController.text = result.name != null ? result.name : result.formattedAddress;
                print(result.name);
                var encoded = Geohash.encode(result.geometry.location.lat,result.geometry.location.lng);
                print(encoded);
              });
              Navigator.of(context).pop();
              setState(() {});
            },
          ),
        ),
      );
    }

I'll try testing on another device as well.

This is what I see on my xcode logs if it helps: locationManager:didUpdateLocations: [CurrentLocationTask dealloc] [LocationTask dealloc] - This take 11 sec to showup

amirhabibz commented 4 years ago

I just noticed that when i move the cursor to select a place and then want to go back to my current location, I have to wait 10-11 second before the current location button functions.

amirhabibz commented 4 years ago

On the IOS simulator it doesn't go past the loading screen, I wasn't able to test on a different IOS phone. This is the best place picker library at the moment but the delay makes this unusable for me. I'm going to have to use another library for the time being.

geekhenno commented 4 years ago

this delay because the default of desired accuracy is high, other libraries we can change it from high to medium, but here we can not.

fysoul17 commented 4 years ago

Hi, @hennonoman Good to hear what was causing the issue.

Fortunately, we have a parameter called [desiredLocationAccuracy] which you can set the desired accuracy.

@amirhabibz, could you try changing the accuracy setting and check if it works?

amirhabibz commented 4 years ago

@hennonoman @fysoul17 Thanks guys! This worked. I'm glad I can use this Library again.

Cheers!

fysoul17 commented 4 years ago

Closing as the issue has been solved.

SmarterVision commented 2 years ago

Hello @fysoul17 @amirhabibz, I still have the problem of 10 seconds to load the current location on IOS can please let me know what you change to fix it

martin-braun commented 2 years ago

@SmarterVision For now, check my fork, this might work out with you. Things will probably take a while until they are fixed here. No offensive towards the author though, he is just too busy right now.

gsoykan commented 2 years ago

Hi all, I've been facing with the same issue for long time. But in the end I was able to find out the primary reason why this takes long for me and finally found a solution for that. The first thing I realized that was the map was loading slowly only when I enabled "useCurrentLocation". Then I did little bit of research and realized that currentLocation actually comes from "geolocator" package which also suffers from the same slowness issue when getting the current location until a very recent version 8.2.0. However, place picker as it is depends on geolocators 7th version in comparison to @martin-braun 's package which depends on ^8.0.0. So solution: Change to @martin-braun 's fork and add geolocator: ^8.2.0 to your pubspec.yaml.

martin-braun commented 2 years ago

@gsoykan Thank you. My new version 2.0.0-mb.14 is up. It should be fixed without the need of a more recent geolocator package in your pubspec.yaml.