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

Remove reference to 'google' object in locationpicker.defaults #140

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

timbkbasic
Copy link

Remove reference to the global 'google' object in locationpicker.defaults to fix problem with 'google not defined' error when using 'async defer' to load the google maps script.

When loading the google maps scripts with 'async defer', the 'google' global object may not be defined at the moment that the locationpicker.jquery script is loaded. Thus, any reference to the 'google' object must be tied to the callback function provided to the google maps script load:

<script async defer src="http://maps.googleapis.com/maps/api/js?key=APIKEY&callback=initCallbackFunction" ></script>

The only place that this is a problem is in locationpicker's 'locationpicker.defaults' initialization, which can possibly run before 'google' has been defined. The problem is that this code references 'google.maps.MapTypeId.ROADMAP'. By changing this to the string that this constant defines - 'roadmap' - we eliminate any reference to 'google' until we actually utilize the locationpicker function, which can be tied to the callback function, which guarantees that 'google' is defined.

…ults to fix problem with 'google not defined' error when using 'async defer' to load the google maps script.
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

Successfully merging this pull request may close these issues.

1 participant