if(map==NO_MAP){
map = null;
}
IProject project = project2;
if (project == null) {
if (map == null)
project = ProjectPlugin.getPlugin().getProjectRegistry()
.getCurrentProject();
else
project = map.getProject();
}
List<? extends ILayer> layers;
/*
* Check or not for duplicate layers in context of the map where georesources are added.
*/
List<IGeoResource> cleanedGeoResources;
if(ProjectPlugin.getPlugin().getPluginPreferences().getBoolean(PreferenceConstants.P_CHECK_DUPLICATE_LAYERS)){
cleanedGeoResources = ProjectUtil.cleanDuplicateGeoResources(resourceList, map);
}else{
cleanedGeoResources = resourceList;
}
if (map == null) {
CreateMapCommand cmCommand = new CreateMapCommand(null, cleanedGeoResources, project);
project.sendSync(cmCommand);
map = cmCommand.getCreatedMap();
layers=map.getMapLayers();
} else {
AddLayersCommand alCommand = new AddLayersCommand(cleanedGeoResources, startPosition2);
map.sendCommandSync(alCommand);