@@ -67,8 +67,13 @@ module.exports = function createGeo(opts) {
67
67
return new Geo ( opts ) ;
68
68
} ;
69
69
70
- proto . plot = function ( geoCalcData , fullLayout , promises ) {
70
+ proto . plot = function ( geoCalcData , fullLayout , promises , replot ) {
71
71
var _this = this ;
72
+ if ( replot ) return _this . update ( geoCalcData , fullLayout , true ) ;
73
+
74
+ _this . _geoCalcData = geoCalcData ;
75
+ _this . _fullLayout = fullLayout ;
76
+
72
77
var geoLayout = fullLayout [ this . id ] ;
73
78
var geoPromises = [ ] ;
74
79
@@ -79,15 +84,24 @@ proto.plot = function(geoCalcData, fullLayout, promises) {
79
84
break ;
80
85
}
81
86
}
87
+
88
+ var hasMarkerAngles = false ;
82
89
for ( var i = 0 ; i < geoCalcData . length ; i ++ ) {
83
90
var trace = geoCalcData [ 0 ] [ 0 ] . trace ;
84
91
trace . _geo = _this ;
85
92
86
93
if ( trace . locationmode ) {
87
94
needsTopojson = true ;
88
- break ;
95
+ }
96
+
97
+ var marker = trace . marker ;
98
+ if ( marker ) {
99
+ var angle = marker . angle ;
100
+ var angleref = marker . angleref ;
101
+ if ( angle || angleref === 'north' || angleref === 'previous' ) hasMarkerAngles = true ;
89
102
}
90
103
}
104
+ this . _hasMarkerAngles = hasMarkerAngles ;
91
105
92
106
if ( needsTopojson ) {
93
107
var topojsonNameNew = topojsonUtils . getTopojsonName ( geoLayout ) ;
@@ -140,7 +154,7 @@ proto.fetchTopojson = function() {
140
154
} ) ;
141
155
} ;
142
156
143
- proto . update = function ( geoCalcData , fullLayout ) {
157
+ proto . update = function ( geoCalcData , fullLayout , replot ) {
144
158
var geoLayout = fullLayout [ this . id ] ;
145
159
146
160
// important: maps with choropleth traces have a different layer order
@@ -158,11 +172,13 @@ proto.update = function(geoCalcData, fullLayout) {
158
172
}
159
173
}
160
174
161
- var hasInvalidBounds = this . updateProjection ( geoCalcData , fullLayout ) ;
162
- if ( hasInvalidBounds ) return ;
175
+ if ( ! replot ) {
176
+ var hasInvalidBounds = this . updateProjection ( geoCalcData , fullLayout ) ;
177
+ if ( hasInvalidBounds ) return ;
163
178
164
- if ( ! this . viewInitial || this . scope !== geoLayout . scope ) {
165
- this . saveViewInitial ( geoLayout ) ;
179
+ if ( ! this . viewInitial || this . scope !== geoLayout . scope ) {
180
+ this . saveViewInitial ( geoLayout ) ;
181
+ }
166
182
}
167
183
this . scope = geoLayout . scope ;
168
184
@@ -180,7 +196,7 @@ proto.update = function(geoCalcData, fullLayout) {
180
196
var choroplethLayer = this . layers . backplot . select ( '.choroplethlayer' ) ;
181
197
this . dataPaths . choropleth = choroplethLayer . selectAll ( 'path' ) ;
182
198
183
- this . render ( ) ;
199
+ this . _render ( ) ;
184
200
} ;
185
201
186
202
proto . updateProjection = function ( geoCalcData , fullLayout ) {
@@ -594,8 +610,16 @@ proto.saveViewInitial = function(geoLayout) {
594
610
Lib . extendFlat ( this . viewInitial , extra ) ;
595
611
} ;
596
612
613
+ proto . render = function ( mayRedrawOnUpdates ) {
614
+ if ( this . _hasMarkerAngles && mayRedrawOnUpdates ) {
615
+ this . plot ( this . _geoCalcData , this . _fullLayout , [ ] , true ) ;
616
+ } else {
617
+ this . _render ( ) ;
618
+ }
619
+ } ;
620
+
597
621
// [hot code path] (re)draw all paths which depend on the projection
598
- proto . render = function ( ) {
622
+ proto . _render = function ( ) {
599
623
var projection = this . projection ;
600
624
var pathFn = projection . getPath ( ) ;
601
625
var k ;
@@ -622,7 +646,7 @@ proto.render = function() {
622
646
for ( k in this . dataPoints ) {
623
647
this . dataPoints [ k ]
624
648
. attr ( 'display' , hideShowPoints )
625
- . attr ( 'transform' , translatePoints ) ;
649
+ . attr ( 'transform' , translatePoints ) ; // TODO: need to redraw points with marker angle instead of calling translatePoints
626
650
}
627
651
} ;
628
652
0 commit comments