Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ https://developers.google.com/maps/documentation/javascript/get-api-key
Limits:
* Location restriction is not supported. See google issue tracker for more info: https://issuetracker.google.com/issues/36219203

add this script to your index.html . you can combine with another google maps library, more info: https://developers.google.com/maps/documentation/javascript/libraries#libraries-for-dynamic-library-import

```dart
<script src="https://maps.googleapis.com/maps/api/js?key={YOUR_API_KEY}&libraries=places&callback=initMap"></script>
```

## Rational

By now you probably found some other plugins, and wondering why this one was even created.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,23 +61,7 @@ class FlutterGooglePlacesSdkWebPlugin extends FlutterGooglePlacesSdkPlatform {

_initMap = allowInterop(_doInit);

html.Element? scriptExist =
html.window.document.querySelector('#$_SCRIPT_ID');
if (scriptExist != null) {
_doInit();
} else {
final body = html.window.document.querySelector('body')!;
var src =
'https://maps.googleapis.com/maps/api/js?key=${apiKey}&loading=async&libraries=places&callback=initMap';
if (locale?.languageCode != null) {
_language = locale?.languageCode;
}
body.append(html.ScriptElement()
..id = _SCRIPT_ID
..src = src
..async = true
..type = 'application/javascript');
}
_doInit();

return completer.future.then((_) {});
}
Expand Down