1- /*! angular-google-maps 2.0.7 2014-11-11
1+ /*! angular-google-maps 2.0.7 2014-11-16
22 * AngularJS directives for Google Maps
33 * git: https://github.com/angular-ui/angular-google-maps.git
44 */
@@ -597,8 +597,8 @@ Nicholas McCready - https://twitter.com/nmccready
597597} ) . call ( this ) ;
598598
599599( function ( ) {
600- angular . module ( "google -maps.directives.api.utils" . ns ( ) ) . service ( "EventsHelper" . ns ( ) , [
601- "Logger" . ns ( ) , function ( $log ) {
600+ angular . module ( "uiGmapgoogle -maps.directives.api.utils" ) . service ( "uiGmapEventsHelper" , [
601+ "uiGmapLogger" , function ( $log ) {
602602 return {
603603 setEvents : function ( gObject , scope , model , ignores ) {
604604 if ( angular . isDefined ( scope . events ) && ( scope . events != null ) && angular . isObject ( scope . events ) ) {
@@ -609,16 +609,24 @@ Nicholas McCready - https://twitter.com/nmccready
609609 }
610610 if ( scope . events . hasOwnProperty ( eventName ) && angular . isFunction ( scope . events [ eventName ] ) && ! doIgnore ) {
611611 return google . maps . event . addListener ( gObject , eventName , function ( ) {
612+ if ( ! scope . $evalAsync ) {
613+ scope . $evalAsync = function ( ) { } ;
614+ }
612615 return scope . $evalAsync ( eventHandler . apply ( scope , [ gObject , eventName , model , arguments ] ) ) ;
613616 } ) ;
614617 }
615618 } ) ) ;
616619 }
617620 } ,
618621 removeEvents : function ( listeners ) {
619- return listeners != null ? listeners . forEach ( function ( l ) {
620- return google . maps . event . removeListener ( l ) ;
621- } ) : void 0 ;
622+ if ( ! listeners ) {
623+ return ;
624+ }
625+ return listeners . forEach ( function ( l ) {
626+ if ( l ) {
627+ return google . maps . event . removeListener ( l ) ;
628+ }
629+ } ) ;
622630 }
623631 } ;
624632 }
@@ -1399,16 +1407,16 @@ Nicholas McCready - https://twitter.com/nmccready
13991407} ) . call ( this ) ;
14001408
14011409( function ( ) {
1402- angular . module ( "google -maps.directives.api.utils" . ns ( ) ) . factory ( "PropertyAction" . ns ( ) , [
1403- "Logger" . ns ( ) , function ( Logger ) {
1410+ angular . module ( "uiGmapgoogle -maps.directives.api.utils" ) . factory ( "uiGmapPropertyAction" , [
1411+ "uiGmapLogger" , function ( Logger ) {
14041412 var PropertyAction ;
14051413 PropertyAction = function ( setterFn , isFirstSet , key ) {
14061414 var self ;
14071415 self = this ;
14081416 this . setIfChange = function ( newVal , oldVal ) {
14091417 var callingKey ;
14101418 callingKey = this . exp ;
1411- if ( ! _ . isEqual ( oldVal , newVal || isFirstSet ) ) {
1419+ if ( ! _ . isEqual ( oldVal , newVal ) ) {
14121420 return setterFn ( callingKey , newVal ) ;
14131421 }
14141422 } ;
@@ -2346,7 +2354,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
23462354 } ;
23472355
23482356 function MarkerChildModel ( scope , model , keys , gMap , defaults , doClick , gMarkerManager , doDrawSelf , trackModel , needRedraw ) {
2349- var action , firstTime ;
2357+ var action ;
23502358 this . model = model ;
23512359 this . keys = keys ;
23522360 this . gMap = gMap ;
@@ -2377,32 +2385,34 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
23772385 this . id = this . model [ this . idKey ] ;
23782386 }
23792387 MarkerChildModel . __super__ . constructor . call ( this , scope ) ;
2380- this . setMyScope ( 'all' , this . model , void 0 , true ) ;
23812388 this . scope . getGMarker = ( function ( _this ) {
23822389 return function ( ) {
23832390 return _this . gMarker ;
23842391 } ;
23852392 } ) ( this ) ;
2386- this . createMarker ( this . model ) ;
2387- firstTime = true ;
2393+ this . firstTime = true ;
23882394 if ( this . trackModel ) {
23892395 this . scope . model = this . model ;
23902396 this . scope . $watch ( 'model' , ( function ( _this ) {
23912397 return function ( newValue , oldValue ) {
23922398 var changes ;
23932399 if ( newValue !== oldValue ) {
23942400 changes = _this . getChanges ( newValue , oldValue , IMarker . keys ) ;
2395- return _ . each ( changes , function ( v , k ) {
2396- _this . setMyScope ( k , newValue , oldValue ) ;
2397- return _this . needRedraw = true ;
2398- } ) ;
2401+ if ( ! _this . firstTime ) {
2402+ return _ . each ( changes , function ( v , k ) {
2403+ _this . setMyScope ( k , newValue , oldValue ) ;
2404+ return _this . needRedraw = true ;
2405+ } ) ;
2406+ }
23992407 }
24002408 } ;
24012409 } ) ( this ) , true ) ;
24022410 } else {
24032411 action = new PropertyAction ( ( function ( _this ) {
24042412 return function ( calledKey , newVal ) {
2405- return _this . setMyScope ( calledKey , scope ) ;
2413+ if ( ! _this . firstTime ) {
2414+ return _this . setMyScope ( calledKey , scope ) ;
2415+ }
24062416 } ;
24072417 } ) ( this ) , false ) ;
24082418 _ . each ( this . keys , function ( v , k ) {
@@ -2414,6 +2424,8 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
24142424 return destroy ( _this ) ;
24152425 } ;
24162426 } ) ( this ) ) ;
2427+ this . setMyScope ( 'all' , this . model , void 0 , true ) ;
2428+ this . createMarker ( this . model ) ;
24172429 $log . info ( this ) ;
24182430 }
24192431
@@ -2465,16 +2477,20 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
24652477 if ( isInit == null ) {
24662478 isInit = false ;
24672479 }
2468- return this . maybeSetScopeValue ( 'options' , model , oldModel , this . optionsKey , this . evalModelHandle , isInit , this . setOptions ) ;
2480+ this . maybeSetScopeValue ( 'options' , model , oldModel , this . optionsKey , this . evalModelHandle , isInit , this . setOptions ) ;
2481+ return this . firstTime = false ;
24692482 } ;
24702483
24712484 MarkerChildModel . prototype . maybeSetScopeValue = function ( scopePropName , model , oldModel , modelKey , evaluate , isInit , gSetter ) {
2472- var newValue , oldVal ;
2485+ var newValue , oldVal , toSet ;
24732486 if ( gSetter == null ) {
24742487 gSetter = void 0 ;
24752488 }
24762489 if ( oldModel === void 0 ) {
2477- this . scope [ scopePropName ] = evaluate ( model , modelKey ) ;
2490+ toSet = evaluate ( model , modelKey ) ;
2491+ if ( toSet !== this . scope [ scopePropName ] ) {
2492+ this . scope [ scopePropName ] = toSet ;
2493+ }
24782494 if ( gSetter != null ) {
24792495 gSetter ( this . scope ) ;
24802496 }
@@ -2547,9 +2563,11 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
25472563 if ( ( this . gMarker != null ) && ( this . isLabel ( this . gMarker === this . isLabel ( this . opts ) ) ) ) {
25482564 this . gMarker . setOptions ( this . opts ) ;
25492565 } else {
2550- if ( this . gMarker != null ) {
2551- this . gMarkerManager . remove ( this . gMarker ) ;
2552- this . gMarker = null ;
2566+ if ( ! this . firstTime ) {
2567+ if ( this . gMarker != null ) {
2568+ this . gMarkerManager . remove ( this . gMarker ) ;
2569+ this . gMarker = null ;
2570+ }
25532571 }
25542572 }
25552573 if ( ! this . gMarker ) {
@@ -2948,13 +2966,15 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
29482966 __extends = function ( child , parent ) { for ( var key in parent ) { if ( __hasProp . call ( parent , key ) ) child [ key ] = parent [ key ] ; } function ctor ( ) { this . constructor = child ; } ctor . prototype = parent . prototype ; child . prototype = new ctor ( ) ; child . __super__ = parent . prototype ; return child ; } ;
29492967
29502968 angular . module ( 'uiGmapgoogle-maps.directives.api.models.child' ) . factory ( 'uiGmapWindowChildModel' , [
2951- 'uiGmapBaseObject' , 'uiGmapGmapUtil' , 'uiGmapLogger' , '$compile' , '$http' , '$templateCache' , 'uiGmapChromeFixes' , function ( BaseObject , GmapUtil , $log , $compile , $http , $templateCache , ChromeFixes ) {
2969+ 'uiGmapBaseObject' , 'uiGmapGmapUtil' , 'uiGmapLogger' , '$compile' , '$http' , '$templateCache' , 'uiGmapChromeFixes' , 'uiGmapEventsHelper' , function ( BaseObject , GmapUtil , $log , $compile , $http , $templateCache , ChromeFixes , EventsHelper ) {
29522970 var WindowChildModel ;
29532971 WindowChildModel = ( function ( _super ) {
29542972 __extends ( WindowChildModel , _super ) ;
29552973
29562974 WindowChildModel . include ( GmapUtil ) ;
29572975
2976+ WindowChildModel . include ( EventsHelper ) ;
2977+
29582978 function WindowChildModel ( model , scope , opts , isIconVisibleOnClick , mapCtrl , markerScope , element , needToManualDestroy , markerIsVisibleAfterWindowClose ) {
29592979 this . model = model ;
29602980 this . scope = scope ;
@@ -2983,7 +3003,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
29833003 return ( _ref1 = this . markerScope ) != null ? _ref1 . getGMarker ( ) : void 0 ;
29843004 }
29853005 } ;
2986- this . googleMapsHandles = [ ] ;
3006+ this . listeners = [ ] ;
29873007 this . createGWin ( ) ;
29883008 if ( this . getGmarker ( ) != null ) {
29893009 this . getGmarker ( ) . setClickable ( true ) ;
@@ -3058,7 +3078,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
30583078 }
30593079 this . handleClick ( ( _ref = this . scope ) != null ? ( _ref1 = _ref . options ) != null ? _ref1 . forceClick : void 0 : void 0 ) ;
30603080 this . doShow ( ) ;
3061- return this . googleMapsHandles . push ( google . maps . event . addListener ( this . gWin , 'closeclick' , ( function ( _this ) {
3081+ return this . listeners . push ( google . maps . event . addListener ( this . gWin , 'closeclick' , ( function ( _this ) {
30623082 return function ( ) {
30633083 if ( _this . getGmarker ( ) ) {
30643084 _this . getGmarker ( ) . setAnimation ( _this . oldMarkerAnimation ) ;
@@ -3123,7 +3143,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
31233143 } ;
31243144
31253145 WindowChildModel . prototype . handleClick = function ( forceClick ) {
3126- var click ;
3146+ var click , marker ;
31273147 if ( this . gWin == null ) {
31283148 return ;
31293149 }
@@ -3154,8 +3174,13 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
31543174 if ( forceClick ) {
31553175 click ( ) ;
31563176 }
3157- if ( this . getGmarker ( ) ) {
3158- return this . googleMapsHandles . push ( google . maps . event . addListener ( this . getGmarker ( ) , 'click' , click ) ) ;
3177+ marker = this . getGmarker ( ) ;
3178+ if ( marker ) {
3179+ return this . listeners = this . listeners . concat ( this . setEvents ( marker , {
3180+ events : {
3181+ click : click
3182+ }
3183+ } , this . model ) ) ;
31593184 }
31603185 } ;
31613186
@@ -3222,24 +3247,21 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
32223247
32233248 WindowChildModel . prototype . remove = function ( ) {
32243249 this . hideWindow ( ) ;
3225- _ . each ( this . googleMapsHandles , function ( h ) {
3226- return google . maps . event . removeListener ( h ) ;
3227- } ) ;
3228- this . googleMapsHandles . length = 0 ;
3250+ this . removeEvents ( this . listeners ) ;
3251+ this . listeners . length = 0 ;
32293252 delete this . gWin ;
32303253 return delete this . opts ;
32313254 } ;
32323255
32333256 WindowChildModel . prototype . destroy = function ( manualOverride ) {
3234- var self , _ref ;
3257+ var _ref ;
32353258 if ( manualOverride == null ) {
32363259 manualOverride = false ;
32373260 }
32383261 this . remove ( ) ;
3239- if ( ( this . scope != null ) && ( ( _ref = this . scope ) != null ? _ref . $$destroyed : void 0 ) && ( this . needToManualDestroy || manualOverride ) ) {
3240- this . scope . $destroy ( ) ;
3262+ if ( ( this . scope != null ) && ! ( ( _ref = this . scope ) != null ? _ref . $$destroyed : void 0 ) && ( this . needToManualDestroy || manualOverride ) ) {
3263+ return this . scope . $destroy ( ) ;
32413264 }
3242- return self = void 0 ;
32433265 } ;
32443266
32453267 return WindowChildModel ;
@@ -3727,7 +3749,17 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
37273749 }
37283750 } ;
37293751 } ) ( this ) ) ;
3730- this . watch ( 'models' , scope , ! this . isTrue ( attrs . modelsbyref ) ) ;
3752+ if ( ( scope . models == null ) || scope . models . length === 0 ) {
3753+ this . modelsRendered = false ;
3754+ }
3755+ this . scope . $watch ( 'models' , ( function ( _this ) {
3756+ return function ( newValue , oldValue ) {
3757+ if ( ! _ . isEqual ( newValue , oldValue ) || ! _this . modelsRendered ) {
3758+ _this . modelsRendered = true ;
3759+ return _this . onWatch ( 'models' , scope , newValue , oldValue ) ;
3760+ }
3761+ } ;
3762+ } ) ( this ) , ! this . isTrue ( attrs . modelsbyref ) ) ;
37313763 this . watch ( 'doCluster' , scope ) ;
37323764 this . watch ( 'clusterOptions' , scope ) ;
37333765 this . watch ( 'clusterEvents' , scope ) ;
@@ -6833,7 +6865,7 @@ angular.module('google-maps.wrapped'.ns()).service('GoogleMapsUtilV3'.ns(), func
68336865 return {
68346866 init : _ . once ( function ( ) {
68356867 //BEGIN REPLACE
6836- /*! angular-google-maps 2.0.7 2014-11-11
6868+ /*! angular-google-maps 2.0.7 2014-11-16
68376869 * AngularJS directives for Google Maps
68386870 * git: https://github.com/angular-ui/angular-google-maps.git
68396871 */
0 commit comments