Skip to content

Loader reports warning when using importLibrary multiple times #809

Closed
@usefulthink

Description

@usefulthink

When loading the maps library followed by another library using loader.importLibrary() and async/await syntax, a misleading warning-message "Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match." is written to the console.

Here's the code that triggers this behavior:

import Loader from '@googlemaps/js-api-loader';

async function main() {
  const loader = new Loader({apiKey: 'MY_API_KEY'});

  const {Map} = await loader.importLibrary('maps');
  
  // this line will trigger the warning message:
  await loader.importLibrary('marker');
}

The reason appears to be that the done flag isn't correctly set to true after the maps-api has initially been loaded.

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p1Important issue which blocks shipping the next release. Will be fixed prior to next release.type: bugError or flaw in code with unintended results or allowing sub-optimal usage patterns.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions