A very common use case in Lucy consists of executing a piece of code once for each map. For example, you want to insert a new action on each map. This includes all the maps that are already available, and all future maps.

You can execute code for all those maps by registering a ILcyGenericMapManagerListener to the map manager:

ILcyLucyEnv lucy = ...;

//Retrieve the map manager
TLcyCombinedMapManager mapManager = lucy.getCombinedMapManager();

//Create the listener using a factory method, and indicate the type of view we are interested in
//When the view type is not specified, the listener will be triggered for all the maps,
//independent of their type
ILcyGenericMapManagerListener<ILcdView, ILcdLayer> listener = ILcyGenericMapManagerListener.onMapAdded(ILspView.class, map -> {
  //do something with the new Lightspeed map
});

//Register the listener
//Note the true as second argument
//This will trigger the listener for each of the already available maps
combinedMapManager.addMapManagerListener(listener, true);