@@ -61,14 +61,17 @@ function UpdateProjection(props) {
6161 *
6262 * @returns {void }
6363 */
64- const clearLayers = function ( ) {
64+ const clearLayers = function ( saveCache ) {
6565 const activeLayersUI = ui . selected
6666 . getLayers ( )
6767 . getArray ( )
6868 . slice ( 0 ) ;
6969 lodashEach ( activeLayersUI , ( mapLayer ) => {
7070 ui . selected . removeLayer ( mapLayer ) ;
7171 } ) ;
72+
73+ if ( saveCache ) return ;
74+ ui . cache . clear ( ) ;
7275 } ;
7376
7477 /**
@@ -116,7 +119,7 @@ function UpdateProjection(props) {
116119 * @param {Boolean } id - layer id
117120 * @returns {void }
118121 */
119- async function reloadLayers ( granuleOptions ) {
122+ async function reloadLayers ( granuleOptions , saveCache ) {
120123 const mapUI = ui . selected ;
121124 const { createLayer } = ui ;
122125
@@ -125,7 +128,7 @@ function UpdateProjection(props) {
125128 if ( compareMapDestroyed ) {
126129 compareMapUi . destroy ( ) ;
127130 }
128- clearLayers ( ) ;
131+ clearLayers ( saveCache ) ;
129132 const defs = getLayers ( layerState , { reverse : true } ) ;
130133 const layerPromises = defs . map ( ( def ) => {
131134 const options = getGranuleOptions ( layerState , def , compare . activeString , granuleOptions ) ;
@@ -138,7 +141,7 @@ function UpdateProjection(props) {
138141 if ( compare && ! compare . isCompareA && compare . mode === 'spy' ) {
139142 stateArray . reverse ( ) ; // Set Layer order based on active A|B group
140143 }
141- clearLayers ( ) ;
144+ clearLayers ( saveCache ) ;
142145 const stateArrayGroups = stateArray . map ( async ( arr ) => getCompareLayerGroup ( arr , layerState , granuleOptions ) ) ;
143146 const compareLayerGroups = await Promise . all ( stateArrayGroups ) ;
144147 compareLayerGroups . forEach ( ( layerGroup ) => mapUI . addLayer ( layerGroup ) ) ;
@@ -222,7 +225,7 @@ function UpdateProjection(props) {
222225
223226 updateMapUI ( ui , rotation ) ;
224227
225- reloadLayers ( ) ;
228+ reloadLayers ( null , ! start ) ;
226229
227230 // If the browser was resized, the inactive map was not notified of
228231 // the event. Force the update no matter what and reposition the center
0 commit comments