1
- /*! angular-google-maps 2.0.7 2014-11-11
1
+ /*! angular-google-maps 2.0.7 2014-11-16
2
2
* AngularJS directives for Google Maps
3
3
* git: https://github.com/angular-ui/angular-google-maps.git
4
4
*/
@@ -597,8 +597,8 @@ Nicholas McCready - https://twitter.com/nmccready
597
597
} ) . call ( this ) ;
598
598
599
599
( 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 ) {
602
602
return {
603
603
setEvents : function ( gObject , scope , model , ignores ) {
604
604
if ( angular . isDefined ( scope . events ) && ( scope . events != null ) && angular . isObject ( scope . events ) ) {
@@ -609,16 +609,24 @@ Nicholas McCready - https://twitter.com/nmccready
609
609
}
610
610
if ( scope . events . hasOwnProperty ( eventName ) && angular . isFunction ( scope . events [ eventName ] ) && ! doIgnore ) {
611
611
return google . maps . event . addListener ( gObject , eventName , function ( ) {
612
+ if ( ! scope . $evalAsync ) {
613
+ scope . $evalAsync = function ( ) { } ;
614
+ }
612
615
return scope . $evalAsync ( eventHandler . apply ( scope , [ gObject , eventName , model , arguments ] ) ) ;
613
616
} ) ;
614
617
}
615
618
} ) ) ;
616
619
}
617
620
} ,
618
621
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
+ } ) ;
622
630
}
623
631
} ;
624
632
}
@@ -1399,16 +1407,16 @@ Nicholas McCready - https://twitter.com/nmccready
1399
1407
} ) . call ( this ) ;
1400
1408
1401
1409
( 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 ) {
1404
1412
var PropertyAction ;
1405
1413
PropertyAction = function ( setterFn , isFirstSet , key ) {
1406
1414
var self ;
1407
1415
self = this ;
1408
1416
this . setIfChange = function ( newVal , oldVal ) {
1409
1417
var callingKey ;
1410
1418
callingKey = this . exp ;
1411
- if ( ! _ . isEqual ( oldVal , newVal || isFirstSet ) ) {
1419
+ if ( ! _ . isEqual ( oldVal , newVal ) ) {
1412
1420
return setterFn ( callingKey , newVal ) ;
1413
1421
}
1414
1422
} ;
@@ -2346,7 +2354,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2346
2354
} ;
2347
2355
2348
2356
function MarkerChildModel ( scope , model , keys , gMap , defaults , doClick , gMarkerManager , doDrawSelf , trackModel , needRedraw ) {
2349
- var action , firstTime ;
2357
+ var action ;
2350
2358
this . model = model ;
2351
2359
this . keys = keys ;
2352
2360
this . gMap = gMap ;
@@ -2377,32 +2385,34 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2377
2385
this . id = this . model [ this . idKey ] ;
2378
2386
}
2379
2387
MarkerChildModel . __super__ . constructor . call ( this , scope ) ;
2380
- this . setMyScope ( 'all' , this . model , void 0 , true ) ;
2381
2388
this . scope . getGMarker = ( function ( _this ) {
2382
2389
return function ( ) {
2383
2390
return _this . gMarker ;
2384
2391
} ;
2385
2392
} ) ( this ) ;
2386
- this . createMarker ( this . model ) ;
2387
- firstTime = true ;
2393
+ this . firstTime = true ;
2388
2394
if ( this . trackModel ) {
2389
2395
this . scope . model = this . model ;
2390
2396
this . scope . $watch ( 'model' , ( function ( _this ) {
2391
2397
return function ( newValue , oldValue ) {
2392
2398
var changes ;
2393
2399
if ( newValue !== oldValue ) {
2394
2400
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
+ }
2399
2407
}
2400
2408
} ;
2401
2409
} ) ( this ) , true ) ;
2402
2410
} else {
2403
2411
action = new PropertyAction ( ( function ( _this ) {
2404
2412
return function ( calledKey , newVal ) {
2405
- return _this . setMyScope ( calledKey , scope ) ;
2413
+ if ( ! _this . firstTime ) {
2414
+ return _this . setMyScope ( calledKey , scope ) ;
2415
+ }
2406
2416
} ;
2407
2417
} ) ( this ) , false ) ;
2408
2418
_ . each ( this . keys , function ( v , k ) {
@@ -2414,6 +2424,8 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2414
2424
return destroy ( _this ) ;
2415
2425
} ;
2416
2426
} ) ( this ) ) ;
2427
+ this . setMyScope ( 'all' , this . model , void 0 , true ) ;
2428
+ this . createMarker ( this . model ) ;
2417
2429
$log . info ( this ) ;
2418
2430
}
2419
2431
@@ -2465,16 +2477,20 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2465
2477
if ( isInit == null ) {
2466
2478
isInit = false ;
2467
2479
}
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 ;
2469
2482
} ;
2470
2483
2471
2484
MarkerChildModel . prototype . maybeSetScopeValue = function ( scopePropName , model , oldModel , modelKey , evaluate , isInit , gSetter ) {
2472
- var newValue , oldVal ;
2485
+ var newValue , oldVal , toSet ;
2473
2486
if ( gSetter == null ) {
2474
2487
gSetter = void 0 ;
2475
2488
}
2476
2489
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
+ }
2478
2494
if ( gSetter != null ) {
2479
2495
gSetter ( this . scope ) ;
2480
2496
}
@@ -2547,9 +2563,11 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2547
2563
if ( ( this . gMarker != null ) && ( this . isLabel ( this . gMarker === this . isLabel ( this . opts ) ) ) ) {
2548
2564
this . gMarker . setOptions ( this . opts ) ;
2549
2565
} 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
+ }
2553
2571
}
2554
2572
}
2555
2573
if ( ! this . gMarker ) {
@@ -2948,13 +2966,15 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2948
2966
__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 ; } ;
2949
2967
2950
2968
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 ) {
2952
2970
var WindowChildModel ;
2953
2971
WindowChildModel = ( function ( _super ) {
2954
2972
__extends ( WindowChildModel , _super ) ;
2955
2973
2956
2974
WindowChildModel . include ( GmapUtil ) ;
2957
2975
2976
+ WindowChildModel . include ( EventsHelper ) ;
2977
+
2958
2978
function WindowChildModel ( model , scope , opts , isIconVisibleOnClick , mapCtrl , markerScope , element , needToManualDestroy , markerIsVisibleAfterWindowClose ) {
2959
2979
this . model = model ;
2960
2980
this . scope = scope ;
@@ -2983,7 +3003,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
2983
3003
return ( _ref1 = this . markerScope ) != null ? _ref1 . getGMarker ( ) : void 0 ;
2984
3004
}
2985
3005
} ;
2986
- this . googleMapsHandles = [ ] ;
3006
+ this . listeners = [ ] ;
2987
3007
this . createGWin ( ) ;
2988
3008
if ( this . getGmarker ( ) != null ) {
2989
3009
this . getGmarker ( ) . setClickable ( true ) ;
@@ -3058,7 +3078,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3058
3078
}
3059
3079
this . handleClick ( ( _ref = this . scope ) != null ? ( _ref1 = _ref . options ) != null ? _ref1 . forceClick : void 0 : void 0 ) ;
3060
3080
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 ) {
3062
3082
return function ( ) {
3063
3083
if ( _this . getGmarker ( ) ) {
3064
3084
_this . getGmarker ( ) . setAnimation ( _this . oldMarkerAnimation ) ;
@@ -3123,7 +3143,7 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3123
3143
} ;
3124
3144
3125
3145
WindowChildModel . prototype . handleClick = function ( forceClick ) {
3126
- var click ;
3146
+ var click , marker ;
3127
3147
if ( this . gWin == null ) {
3128
3148
return ;
3129
3149
}
@@ -3154,8 +3174,13 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3154
3174
if ( forceClick ) {
3155
3175
click ( ) ;
3156
3176
}
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 ) ) ;
3159
3184
}
3160
3185
} ;
3161
3186
@@ -3222,24 +3247,21 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3222
3247
3223
3248
WindowChildModel . prototype . remove = function ( ) {
3224
3249
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 ;
3229
3252
delete this . gWin ;
3230
3253
return delete this . opts ;
3231
3254
} ;
3232
3255
3233
3256
WindowChildModel . prototype . destroy = function ( manualOverride ) {
3234
- var self , _ref ;
3257
+ var _ref ;
3235
3258
if ( manualOverride == null ) {
3236
3259
manualOverride = false ;
3237
3260
}
3238
3261
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 ( ) ;
3241
3264
}
3242
- return self = void 0 ;
3243
3265
} ;
3244
3266
3245
3267
return WindowChildModel ;
@@ -3727,7 +3749,17 @@ Original idea from: http://stackoverflow.com/questions/22758950/google-map-drawi
3727
3749
}
3728
3750
} ;
3729
3751
} ) ( 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 ) ) ;
3731
3763
this . watch ( 'doCluster' , scope ) ;
3732
3764
this . watch ( 'clusterOptions' , scope ) ;
3733
3765
this . watch ( 'clusterEvents' , scope ) ;
@@ -6833,7 +6865,7 @@ angular.module('google-maps.wrapped'.ns()).service('GoogleMapsUtilV3'.ns(), func
6833
6865
return {
6834
6866
init : _ . once ( function ( ) {
6835
6867
//BEGIN REPLACE
6836
- /*! angular-google-maps 2.0.7 2014-11-11
6868
+ /*! angular-google-maps 2.0.7 2014-11-16
6837
6869
* AngularJS directives for Google Maps
6838
6870
* git: https://github.com/angular-ui/angular-google-maps.git
6839
6871
*/
0 commit comments