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

webpack/@googlemaps/js-api-loader: #1

Open
strarsis opened this issue Apr 25, 2020 · 3 comments
Open

webpack/@googlemaps/js-api-loader: #1

strarsis opened this issue Apr 25, 2020 · 3 comments

Comments

@strarsis
Copy link

When using map-label-rotated with @googlemaps/js-api-loader and building with webpack, I get an error during runtime when trying to create a rotated label:

Uncaught ReferenceError: google is not defined
    at Object.<anonymous> (make-control.js:23)
    at __webpack_require__ (bootstrap 9ec78d170b869e843be0:19)
    at Object.<anonymous> (some-js-file.js:1)
    at __webpack_require__ (bootstrap 9ec78d170b869e843be0:19)
    at Object.<anonymous> (main.js:1)
    at Object.<anonymous> (main.js:34)
    at __webpack_require__ (bootstrap 9ec78d170b869e843be0:19)
    at Object.<anonymous> (index.js:240)
    at __webpack_require__ (bootstrap 9ec78d170b869e843be0:19)
    at bootstrap 9ec78d170b869e843be0:62
import { RotatedLabel }  from 'map-label-rotated';
[...]
const label = new RotatedLabel( bounds.getCenter(), 'Test', 45, map );
@javidalpe
Copy link
Owner

Hey @strarsis, I have updated the class so it extends from window.google instead of google. Could you check now?

@strarsis
Copy link
Author

strarsis commented Jul 1, 2020

@javidalpe: Awesome! Thanks for the modification. When I got some more time I will test it and give feedback.

@strarsis
Copy link
Author

strarsis commented Sep 11, 2021

@javidalpe: So after about a year I finally got back to that project. 😮 ⏲️

The issue is that the google maps loader will set google.maps asynchronously.
I import this map-label-rotated library and it will immediately try to use the global variable for google maps,
as it extends it directly in its defintion:
export class RotatedLabel extends window.google.maps.OverlayView {

I don't know if this can be easily changed. I guess I have to asynchronously import this library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants