@@ -54,17 +54,25 @@ function calcGeoJSON(calcTrace, fullLayout) {
5454 calcPt . _polygons = geoUtils . feature2polygons ( feature ) ;
5555
5656 var bboxFeature = geoUtils . computeBbox ( feature ) ;
57- lonArray . push ( bboxFeature [ 0 ] , bboxFeature [ 2 ] ) ;
58- latArray . push ( bboxFeature [ 1 ] , bboxFeature [ 3 ] ) ;
57+ if ( bboxFeature ) {
58+ const [ west , south , east , north ] = bboxFeature ;
59+ lonArray . push ( west , east ) ;
60+ latArray . push ( south , north ) ;
61+ }
5962 } else {
6063 calcPt . geojson = null ;
6164 }
6265 }
6366
6467 if ( geoLayout . fitbounds === 'geojson' && locationmode === 'geojson-id' ) {
6568 var bboxGeojson = geoUtils . computeBbox ( geoUtils . getTraceGeojson ( trace ) ) ;
66- lonArray = [ bboxGeojson [ 0 ] , bboxGeojson [ 2 ] ] ;
67- latArray = [ bboxGeojson [ 1 ] , bboxGeojson [ 3 ] ] ;
69+ // Falsy bbox (Sphere / malformed / empty geojson) falls through to the
70+ // per-feature bounds populated above, effectively the same as fitBounds === 'locations'.
71+ if ( bboxGeojson ) {
72+ const [ west , south , east , north ] = bboxGeojson ;
73+ lonArray = [ west , east ] ;
74+ latArray = [ south , north ] ;
75+ }
6876 }
6977
7078 var opts = { padded : true } ;
@@ -73,6 +81,6 @@ function calcGeoJSON(calcTrace, fullLayout) {
7381}
7482
7583module . exports = {
76- calcGeoJSON : calcGeoJSON ,
77- plot : plot
84+ calcGeoJSON,
85+ plot
7886} ;
0 commit comments