function removeToolbarMapButton(tb, mapButtonName)
%removeToolbarMapButton Remove map button from toolbar
%
%   removeToolbarMapButton(TB) removes all map buttons from the toolbar
%   specified by TB. TB is an axes toolbar in a geographic axes and can be
%   an array.
%
%   removeToolbarMapButton(TB,mapButtonName) removes the map button
%   specified by mapButtonName. Remove a basemap picker button by
%   specifying mapButtonName as "basemap".
%
%   Example
%   -------
%   % Add then remove a basemap picker from the axes toolbar
%   fig = uifigure;
%   gx = geoaxes(fig);
%   tb = axtoolbar(gx,"default");
%   addToolbarMapButton(tb)
%   removeToolbarMapButton(tb)
%
%   See also addToolbarMapButton, geoaxes, uifigure

% Copyright 2021 The MathWorks, Inc.

    arguments
        tb matlab.ui.controls.AxesToolbar {mustBeNonempty}
        mapButtonName map.graphics.datatype.MapButtonName = map.graphics.datatype.MapButtonName.empty
    end

    switch string(mapButtonName)
        case "basemap"
            map.internal.basemaps.removeBasemapPickerToolbarButton(tb)
        otherwise
            % all
            map.internal.basemaps.removeBasemapPickerToolbarButton(tb)
    end
end
