matanshukry / flutter_google_places_sdk

Flutter plugin for google places native sdk
36 stars 75 forks source link

Has conflict with google map #93

Open tazik561 opened 3 months ago

tazik561 commented 3 months ago

When I am using this library with flutter google map in 1 page and I want to get new location and move camera I get this error:

Caught error: InvalidValueError: not a LatLng or LatLngLiteral with finite coordinates: in property lat: not a number

after a lot s of investigation I got the reason is this package. when I removed this package and directly I used Google Place API my issue was solved but when I used this package to get a new location I had the same issue. On the Chrome console, I have these errors:

Screenshot 2024-08-09 at 9 01 01 AM

I also added my config in my HTML :

    <script async
            src="https://maps.googleapis.com/maps/api/js?key=MyKey&loading=async&callback=Function.prototype">
    </script>
anggaaryas commented 3 months ago

same, any other library alternative?

anggaaryas commented 3 months ago

I fix this bug by using this branch: https://github.com/anggaaryas/flutter_google_places_sdk/tree/google_places_sdk_web/remove-ssrc

matanshukry commented 3 months ago

@tazik561 you should not add the <script> tag your self, the library already does it. The aim is for the library to do as much stuff for you as possible

matanshukry commented 3 months ago

As a temporary workaround, I recommend creating your own script with id = flutter_google_places_sdk_web_script_id, before calling the initialize.

@tazik561 fyi

tazik561 commented 3 months ago

As a temporary workaround, I recommend creating your own script with id = flutter_google_places_sdk_web_script_id, before calling the initialize.

@tazik561 FYI

Thanks all Guys but I fixed it before, Just I added this issue to keep logging. Just in your code before adding the script check if Google API was initialized or not. if initialized and there is a Google API script in the Html ignore adding the script again. Locally I fixed it and now everything is ok

like codes I did:

    bool googleMapsLoaded = js.context.hasProperty('google') &&
        js.context['google'].hasProperty('maps');

if (googleMapsLoaded ) {
      _doInit();
    }

This library should have this condition, just in case