@@ -11,6 +11,7 @@ import {
1111 normalizeLayer ,
1212} from "../../../services/VisibleLayer/LayerSources" ;
1313import WithErrors from "../../HOCs/WithErrors/WithErrors" ;
14+ import TileLayerErrorBoundary from "../../TaskClusterMap/TileLayerErrorBoundary" ;
1415
1516/**
1617 * SourcedTileLayer renders a react-leaflet TileLayer from the current
@@ -21,7 +22,7 @@ import WithErrors from "../../HOCs/WithErrors/WithErrors";
2122 *
2223 * @author [Neil Rotstan](https://github.com/nrotstan)
2324 */
24- const SourcedTileLayer = ( props ) => {
25+ const SourcedTileLayerInternal = ( props ) => {
2526 const [ layerRenderFailed , setLayerRenderFailed ] = useState ( false ) ;
2627
2728 const attribution = ( layer ) => {
@@ -35,7 +36,7 @@ const SourcedTileLayer = (props) => {
3536 } ;
3637
3738 useEffect ( ( ) => {
38- if ( layerRenderFailed && currentLayer ) {
39+ if ( layerRenderFailed ) {
3940 setLayerRenderFailed ( false ) ;
4041 }
4142 } , [ props . source . id ] ) ;
@@ -45,7 +46,7 @@ const SourcedTileLayer = (props) => {
4546 }
4647
4748 if ( layerRenderFailed ) {
48- if ( fallbackLayer ) {
49+ if ( props . fallbackLayer ) {
4950 return (
5051 < FormattedMessage
5152 { ...AppErrors . map . renderFailure }
@@ -59,13 +60,20 @@ const SourcedTileLayer = (props) => {
5960
6061 const normalizedLayer = normalizeLayer ( props . source ) ;
6162
63+ const handleTileError = ( ) => {
64+ setLayerRenderFailed ( true ) ;
65+ } ;
66+
6267 if ( normalizedLayer . type === "bing" ) {
6368 return (
6469 < BingLayer
6570 key = { normalizedLayer . id }
6671 { ...normalizedLayer }
6772 type = "Aerial"
6873 attribution = { attribution ( normalizedLayer ) }
74+ eventHandlers = { {
75+ tileerror : handleTileError ,
76+ } }
6977 />
7078 ) ;
7179 }
@@ -75,20 +83,34 @@ const SourcedTileLayer = (props) => {
7583 key = { normalizedLayer . id }
7684 { ...normalizedLayer }
7785 attribution = { attribution ( normalizedLayer ) }
86+ eventHandlers = { {
87+ tileerror : handleTileError ,
88+ } }
7889 { ...props }
7990 />
8091 ) ;
8192} ;
8293
94+ const SourcedTileLayer = ( props ) => {
95+ return (
96+ < TileLayerErrorBoundary sourceId = { props . source ?. id } >
97+ < SourcedTileLayerInternal { ...props } />
98+ </ TileLayerErrorBoundary >
99+ ) ;
100+ } ;
101+
83102SourcedTileLayer . propTypes = {
84103 /** LayerSource to use */
85104 source : layerSourceShape ,
86105 /** Set to true to suppress display of source attribution */
87106 skipAttribution : PropTypes . bool ,
107+ /** Set to true if this is a fallback layer */
108+ fallbackLayer : PropTypes . bool ,
88109} ;
89110
90111SourcedTileLayer . defaultProps = {
91112 skipAttribution : false ,
113+ fallbackLayer : false ,
92114} ;
93115
94116export default WithErrors ( injectIntl ( SourcedTileLayer ) ) ;
0 commit comments