@@ -67,8 +67,13 @@ module.exports = function createGeo(opts) {
6767 return new Geo ( opts ) ;
6868} ;
6969
70- proto . plot = function ( geoCalcData , fullLayout , promises ) {
70+ proto . plot = function ( geoCalcData , fullLayout , promises , replot ) {
7171 var _this = this ;
72+ if ( replot ) return _this . update ( geoCalcData , fullLayout , true ) ;
73+
74+ _this . _geoCalcData = geoCalcData ;
75+ _this . _fullLayout = fullLayout ;
76+
7277 var geoLayout = fullLayout [ this . id ] ;
7378 var geoPromises = [ ] ;
7479
@@ -79,15 +84,24 @@ proto.plot = function(geoCalcData, fullLayout, promises) {
7984 break ;
8085 }
8186 }
87+
88+ var hasMarkerAngles = false ;
8289 for ( var i = 0 ; i < geoCalcData . length ; i ++ ) {
8390 var trace = geoCalcData [ 0 ] [ 0 ] . trace ;
8491 trace . _geo = _this ;
8592
8693 if ( trace . locationmode ) {
8794 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 ;
89102 }
90103 }
104+ this . _hasMarkerAngles = hasMarkerAngles ;
91105
92106 if ( needsTopojson ) {
93107 var topojsonNameNew = topojsonUtils . getTopojsonName ( geoLayout ) ;
@@ -140,7 +154,7 @@ proto.fetchTopojson = function() {
140154 } ) ;
141155} ;
142156
143- proto . update = function ( geoCalcData , fullLayout ) {
157+ proto . update = function ( geoCalcData , fullLayout , replot ) {
144158 var geoLayout = fullLayout [ this . id ] ;
145159
146160 // important: maps with choropleth traces have a different layer order
@@ -158,11 +172,13 @@ proto.update = function(geoCalcData, fullLayout) {
158172 }
159173 }
160174
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 ;
163178
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+ }
166182 }
167183 this . scope = geoLayout . scope ;
168184
@@ -180,7 +196,7 @@ proto.update = function(geoCalcData, fullLayout) {
180196 var choroplethLayer = this . layers . backplot . select ( '.choroplethlayer' ) ;
181197 this . dataPaths . choropleth = choroplethLayer . selectAll ( 'path' ) ;
182198
183- this . render ( ) ;
199+ this . _render ( ) ;
184200} ;
185201
186202proto . updateProjection = function ( geoCalcData , fullLayout ) {
@@ -594,8 +610,16 @@ proto.saveViewInitial = function(geoLayout) {
594610 Lib . extendFlat ( this . viewInitial , extra ) ;
595611} ;
596612
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+
597621// [hot code path] (re)draw all paths which depend on the projection
598- proto . render = function ( ) {
622+ proto . _render = function ( ) {
599623 var projection = this . projection ;
600624 var pathFn = projection . getPath ( ) ;
601625 var k ;
@@ -622,7 +646,7 @@ proto.render = function() {
622646 for ( k in this . dataPoints ) {
623647 this . dataPoints [ k ]
624648 . attr ( 'display' , hideShowPoints )
625- . attr ( 'transform' , translatePoints ) ;
649+ . attr ( 'transform' , translatePoints ) ; // TODO: need to redraw points with marker angle instead of calling translatePoints
626650 }
627651} ;
628652
0 commit comments