File tree Expand file tree Collapse file tree
src/OutSystems/Maps/MapAPI Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -83,12 +83,21 @@ namespace OutSystems.Maps.MapAPI.MapManager {
8383 if ( maps . has ( mapId ) ) {
8484 map = maps . get ( mapId ) ;
8585 } else {
86- //Search for WidgetId
87- for ( const p of maps . values ( ) ) {
88- if ( p . equalsToID ( mapId ) ) {
89- map = p ;
90- break ;
91- }
86+ //Search for (all) the map(s) that have this WidgetId
87+ const mapFiltered = Array . from ( maps . values ( ) ) . filter ( ( p ) => p . equalsToID ( mapId ) ) ;
88+
89+ // There can be situations, for example when changing from a page
90+ // to another page that also has a "Map", in which, we'll end up
91+ // having 2 maps, with different uniqueIds, but same Widget id.
92+ if ( mapFiltered . length > 1 ) {
93+ // If that is the case, we'll pick the last map of that was found
94+ // that will correspond to the last map that was created by the
95+ // application (in these cases, the new map). The other map, is
96+ // the one that will be destroyed afterwards.
97+ map = mapFiltered [ mapFiltered . length - 1 ] ;
98+ } else if ( mapFiltered . length === 1 ) {
99+ // In case only one map was found, we'll return that one
100+ map = mapFiltered [ 0 ] ;
92101 }
93102 }
94103
You can’t perform that action at this time.
0 commit comments