a14n / dart-google-maps

A library to use Google Maps JavaScript API v3 from Dart scripts.
Other
125 stars 63 forks source link

Google Maps JavaScript API has a new loader, should this lib use it (or expose its API)? #119

Closed ditman closed 1 year ago

ditman commented 1 year ago

Working in something unrelated (endorsing google_maps_flutter_web), I just noticed this warning in the JS console:

Warning Google Maps JavaScript API has been loaded directly without a callback. This is not supported and can lead to race conditions and suboptimal performance. For supported loading patterns please see https://goo.gle/js-api-loading

It seems that the Google Maps library has gone "modular", and the "legacy" mode that we're using wants a callback (in my tests everything works without the callback for now, though!).

Should the library adopt/export the new loader syntax?


Here's the full list of libraries that can be loaded through the new importLibrary loader:

a14n commented 1 year ago

In 6.3.0 you can now call importLibrary :

void main() async {
  await importLibrary("maps");
  GMap(
    document.getElementById("map") as HtmlElement,
    MapOptions()
      ..center = LatLng(-34.397, 150.644)
      ..zoom = 8,
  );
}
ditman commented 1 year ago

You're a machine @a14n!