@@ -79,25 +79,23 @@ namespace OutSystems.Maps.MapAPI.MapManager {
7979 export function GetMapById ( mapId : string , raiseError = true ) : OSFramework . Maps . OSMap . IMap {
8080 let map : OSFramework . Maps . OSMap . IMap ;
8181
82- //mapId is the UniqueId
8382 if ( maps . has ( mapId ) ) {
83+ // mapId = uniqueId
8484 map = maps . get ( mapId ) ;
8585 } else {
86- //Search for (all) the map(s) that have this WidgetId
86+ // map = widgetId
87+ // Search for (all) the map(s) that have this WidgetId
8788 const mapFiltered = Array . from ( maps . values ( ) ) . filter ( ( p ) => p . equalsToID ( mapId ) ) ;
8889
8990 // There can be situations, for example when changing from a page
9091 // to another page that also has a "Map", in which, we'll end up
9192 // 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.
93+ if ( mapFiltered . length > 0 ) {
94+ // So we'll always pick the last map of that was found and it
95+ // will correspond to the last map that was created in the app
96+ // (in these cases, the new map). The other map, is the one
97+ // that will be destroyed afterwards.
9798 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 ] ;
10199 }
102100 }
103101
0 commit comments