function [scatterHandle, textHandles] = scatterPositions(pAxesHandle, pSoundsources, pSoundsourceColorRegister, pSoundsourceColors, pPlotAsMap)
%PLOT Summary of this function goes here
%   Detailed explanation goes here

%% Collect required data

fnames = fieldnames(pSoundsources);
plot_names = fnames;

lat = NaN(length(fnames), 1);
lon = NaN(length(fnames), 1);
color = repmat([0 0 0], length(fnames), 1);

for i = 1:length(fnames)
    lat(i) = pSoundsources.(fnames{i}).position(1);
    lon(i) = pSoundsources.(fnames{i}).position(2);
    index = artoa.soundsources.colorregister.getColorIndex(fnames{i}, pSoundsourceColorRegister);
    if index > 0
        color(i, :) = pSoundsourceColors(index, :);
    end
    plot_names{i} = {'', ['  ' plot_names{i}]};
end

%% Plot positions

% make handle the current axes
axes(pAxesHandle);

hold(pAxesHandle, 'on');

if pPlotAsMap
    scatterHandle = scatterm(pAxesHandle, lat, lon, [], color);
    %textHandles = text(pAxesHandle, lon, lat, plot_names, 'Color', [0 0 0]);
    textHandles = textm(lat, lon, plot_names, 'Color', [0 0 0]);
else
    scatterHandle = scatter(pAxesHandle, lon, lat, [], color);
    textHandles = text(pAxesHandle, lon, lat, plot_names, 'Color', [0 0 0]);
    for i = 1:length(textHandles)
        textHandles(i).Color = color(i, :);
    end
end
hold(pAxesHandle, 'off');

end