MATLAB: How to set usamap projection to mercator

Mapping ToolboxMATLABprojectionusamap

I am having trouble setting the projection to mercator for the below map:
ax = usamap([10 90], [-180 -50] );
states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));
oceanColor = [.5 .7 .9];
setm(ax, 'FFaceColor', oceanColor)
geoshow(states)
gridm off;
Would you please help me out?

Best Answer

Hello Leon,
Once you use geoshow to place shapes onto the map, you cannot change the map projection. You could delete all the children, change the projection, and then reuse geoshow. But an easier way is to just set the map projection at the outset:
ax = usamap([10 90], [-180 -50] );
states = geoshape(shaperead('usastatehi', 'UseGeoCoords', true));
oceanColor = [.5 .7 .9];
setm(ax, 'FFaceColor', oceanColor)
setm(ax,'MapProjection','mercator') % ADDED LINE
geoshow(states)
gridm off;
-Cam