Remove reference to 'google' object in locationpicker.defaults #140
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.