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

Reset/Delete/Clear #100

Open
jpoehnelt opened this issue Nov 13, 2020 · 8 comments
Open

Reset/Delete/Clear #100

jpoehnelt opened this issue Nov 13, 2020 · 8 comments
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.

Comments

@jpoehnelt
Copy link
Contributor

jpoehnelt commented Nov 13, 2020

Future feature work could include the ability to reset or clear the singleton, script tag, and window.google. This likely overlaps with #5.

Looking for more feedback on uses cases and waiting for the singleton pattern get some more usage.

Note: This pattern may result in duplicate billing charge...

@jpoehnelt jpoehnelt added type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design. priority: p2 Moderately-important priority. Fix may not be included in next release. labels Nov 13, 2020
@jpoehnelt jpoehnelt added priority: p3 Desirable enhancement or fix. May not be included in next release. and removed priority: p2 Moderately-important priority. Fix may not be included in next release. labels Dec 22, 2020
@TERADA-DANTE
Copy link

@jpoehnelt Does this issue related to browser warning : Aborted attempt to load Google Maps JS with @googlemaps/js-api-loader.This may result in undesirable behavior as script parameters may not match.?

I am wondering if there is any cleanup function to avoid this warning.(I am currently using this library in my NextJS project and try to clean up when component unmounted).

I've found there is deleteScript() method in loader but it's not working when it's used as useEffect return cleanup.

Hope I am at the right window...

@jpoehnelt
Copy link
Contributor Author

Does this issue related to browser warning

I'll change that message to be more specific. The issue is that the loader was called twice which is ok, but the same key, libraries, etc must be used. This could be related to #5 for libraries.

@cristian-rossi
Copy link

I would love to see this. I'm trying to validate a API key for use with the Maps Javascript API and there's no way to do it other than loading the script, try to create a map and wait for gm_authFailure.

So, if the API key is invalid and a new one inserted I have to reload the script and try the map again.

@jpoehnelt
Copy link
Contributor Author

Which aspect are you trying to validate with the API key?

  1. key exists and is valid
  2. key restriction is correct
  3. api enabled for key

related: https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/describe

@cristian-rossi
Copy link

@jpoehnelt On the client side I'm trying to: make sure the key has access to the Javascript API ( https://developers.google.com/maps/documentation/javascript )

I already have something to check other libraries like the places API where I try to call the AutocompleteService and if it fails it probably means the key does not have access to the places API.

@boomfly
Copy link

boomfly commented Jun 4, 2022

Here workaround:

if (loader) {
  loader.reset()
  delete window.google
  Loader.instance = undefined
}

@mageshk98
Copy link

Which aspect are you trying to validate with the API key?

  1. key exists and is valid
  2. key restriction is correct
  3. API enabled for key

related: https://cloud.google.com/sdk/gcloud/reference/alpha/services/api-keys/describe

@jpoehnelt Do we have any method to validate the API key in the criteria you mentioned here? Instead of calling map library, I want to validate because, sometimes the key will be a valid one but it doesn't have access to the library, right?!

Can you please help!!

@crunchwrap89
Copy link

@jpoehnelt
I have a Single Page Application where a new google maps map is created on 3 different routes.

When i switch between these three routes, the memory allocation keeps stacking with 20mb per route switch, because it seems webgl.js doesnt do proper cleanup even if i clear and reset all references in my own src files.

I think a Reset/Delete/Clear feature could help me clean up this memory leak aswell. Preferably in away that doesnt double api calls.

If you want to test it, go to https://mapcanvas3d.com and move between routes in the navigation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: p3 Desirable enhancement or fix. May not be included in next release. type: feature request ‘Nice-to-have’ improvement, new feature or different behavior or design.
Projects
None yet
Development

No branches or pull requests

6 participants