@@ -135,7 +135,7 @@ proto.createMap = function(calcData, fullLayout, resolve, reject) {
135135 Promise . all ( promises ) . then ( function ( ) {
136136 self . fillBelowLookup ( calcData , fullLayout ) ;
137137 self . updateData ( calcData ) ;
138- self . updateLayout ( fullLayout ) ;
138+ self . updateLayout ( fullLayout , true ) ;
139139 self . resolveOnRender ( resolve ) ;
140140 } ) . catch ( reject ) ;
141141} ;
@@ -346,7 +346,7 @@ proto.updateData = function(calcData) {
346346 }
347347} ;
348348
349- proto . updateLayout = function ( fullLayout ) {
349+ proto . updateLayout = function ( fullLayout , initialView ) {
350350 var map = this . map ;
351351 var opts = fullLayout [ this . id ] ;
352352
@@ -365,6 +365,11 @@ proto.updateLayout = function(fullLayout) {
365365 } else {
366366 map . scrollZoom . disable ( ) ;
367367 }
368+ if ( initialView === true ) {
369+ // Add derived properties to viewInitial so they are included in
370+ // the plotly_relayout event that is emitted when the plot is reset
371+ this . viewInitial . _derived = this . getView ( ) . _derived ;
372+ }
368373} ;
369374
370375proto . resolveOnRender = function ( resolve ) {
@@ -747,17 +752,29 @@ proto.getView = function() {
747752 var mapCenter = map . getCenter ( ) ;
748753 var center = { lon : mapCenter . lng , lat : mapCenter . lat } ;
749754
755+ var canvas = map . getCanvas ( ) ;
756+ var w = canvas . width ;
757+ var h = canvas . height ;
758+ var cUL = map . unproject ( [ 0 , 0 ] ) . toArray ( ) ;
759+ var cUR = map . unproject ( [ w , 0 ] ) . toArray ( ) ;
760+ var cLR = map . unproject ( [ w , h ] ) . toArray ( ) ;
761+ var cLL = map . unproject ( [ 0 , h ] ) . toArray ( ) ;
762+ var coordinates = [ cUL , cUR , cLR , cLL ] ;
763+
750764 return {
751765 center : center ,
752766 zoom : map . getZoom ( ) ,
753767 bearing : map . getBearing ( ) ,
754- pitch : map . getPitch ( )
768+ pitch : map . getPitch ( ) ,
769+ _derived : {
770+ coordinates : coordinates
771+ }
755772 } ;
756773} ;
757774
758775proto . getViewEdits = function ( cont ) {
759776 var id = this . id ;
760- var keys = [ 'center' , 'zoom' , 'bearing' , 'pitch' ] ;
777+ var keys = [ 'center' , 'zoom' , 'bearing' , 'pitch' , '_derived' ] ;
761778 var obj = { } ;
762779
763780 for ( var i = 0 ; i < keys . length ; i ++ ) {
0 commit comments