Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Documentation mentions deprecated methods #801

Closed
MrAmericanMike opened this issue Jun 11, 2023 · 10 comments
Closed

Documentation mentions deprecated methods #801

MrAmericanMike opened this issue Jun 11, 2023 · 10 comments
Assignees
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.

Comments

@MrAmericanMike
Copy link

Not much, just reporting this so the documentation can be updated.

On the README.md there are 2 methods for using the library mentioned loader.load() and loader.loadCallback() but both methods are deprecated.

@MrAmericanMike MrAmericanMike added triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns. labels Jun 11, 2023
@wangela
Copy link
Member

wangela commented Jun 11, 2023

If you would like to upvote the priority of this issue, please comment below or react with 👍 so we can see what is popular when we triage.

@MrAmericanMike Thank you for opening this issue. 🙏
Please check out these other resources that might help you get to a resolution in the meantime:

This is an automated message, feel free to ignore.

@higgjd
Copy link

higgjd commented Jun 12, 2023

@MrAmericanMike I can see that this has deprecated too. Do you happen to know what I can use instead of .load?

@MrAmericanMike
Copy link
Author

@MrAmericanMike I can see that this has deprecated too. Do you happen to know what I can use instead of .load?

Yes the one that works is using importLibrary Also mentioned in the documentation. That one works fine.

// Promise for a specific library
loader
  .importLibrary('maps')
  .then(({Map}) => {
    new Map(document.getElementById("map"), mapOptions);
  })
  .catch((e) => {
    // do something
  });

@chrisjshull
Copy link
Contributor

Yes, importLibrary is now recommended over load.

@higgjd
Copy link

higgjd commented Jun 14, 2023

Great thank you both!

@owaisahmed5300
Copy link

Yes, but what if we need to load multiple libraries at once? When I call import Library multiple times I get error:

Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match.

@owaisahmed5300
Copy link

There should be a way to load multiple, maybe importLibrary should accept an array of Library names.

@chrisjshull
Copy link
Contributor

It is intended to be safe to call importLibrary() multiple times. Can you file a new bug to track that (preferably with sample code that exhibits the issue)?

@owaisahmed5300
Copy link

owaisahmed5300 commented Apr 14, 2024

@chrisjshull When calling multiple times importLibrary 1 by 1 with await()

// For example,
maps = await loader.importLibrary('maps');
marker = await loader.importLibrary('marker');

Previously we'd load function and we can easily pass multiple libraries directly to Loader Class Constructor but now after load function is deprecated and importLibrary() is recommended we cannot pass the multiple libraries without getting warning.

Warning: "Google Maps already loaded outside @googlemaps/js-api-loader.This may result in undesirable behavior as options and script parameters may not match."

Solved using Promise.all(): #809

@chrisjshull
Copy link
Contributor

Ah, thanks. I'll comment there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
triage me I really want to be triaged. type: bug Error or flaw in code with unintended results or allowing sub-optimal usage patterns.
Projects
None yet
Development

No branches or pull requests

6 participants