Skip to content

Commit dfb0ea9

Browse files
committed
Merge pull request allenhwkim#161 from itkSource/CheckGoogleMapAlreadyLoaded
Better check of the google map already loaded in lazyload directive
2 parents 5b8257e + ff524ad commit dfb0ea9

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

app/scripts/directives/map-lazy-load.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
/*jshint -W089*/
2424
ngMap.directive('mapLazyLoad', ['$compile', '$timeout', function($compile, $timeout) {
2525
'use strict';
26-
var loaded = false;
2726
var directiveDefinitionObject = {
2827
compile: function(tElement, tAttrs) {
2928
(!tAttrs.mapLazyLoad) && console.error('requires src with map-lazy-load');
@@ -40,13 +39,12 @@ ngMap.directive('mapLazyLoad', ['$compile', '$timeout', function($compile, $time
4039
pre: function(scope, element, attrs) {
4140
window.lazyLoadCallback = function() {
4241
console.log('script loaded,' + src);
43-
loaded = true;
4442
$timeout(function() { /* give some time to load */
4543
element.html(savedHtml);
4644
$compile(element.contents())(scope);
4745
}, 100);
4846
};
49-
if(loaded === false) {
47+
if(window.google === undefined || window.google.maps === undefined) {
5048
var scriptEl = document.createElement('script');
5149
scriptEl.src = src + (src.indexOf('?') > -1 ? '&' : '?') + 'callback=lazyLoadCallback';
5250
document.body.appendChild(scriptEl);

0 commit comments

Comments
 (0)