Hi Jennifer,
It seems you are looking to toggle webmap overlays in MATLAB programmatically. While MATLAB's webmap function does not directly support toggling overlays like "World Boundaries (Light Text)" from a script, you can achieve similar functionality with these workarounds:
- Add custom overlays to a webmap using functions like wmline, wmpolygon, or wmoverlay.
% Open web map
webMapObj = webmap('World Imagery');
% Example coordinates for a rectangular boundary
lat = [40, 40, 41, 41, 40]; % Example latitudes
lon = [-75, -74, -74, -75, -75]; % Example longitudes
% Plot the boundary as a polygon
wmpolygon(lat, lon, 'FaceColor', 'none', 'EdgeColor', 'blue', 'LineWidth', 2);
- If you have specific boundary data in shapefiles or GeoJSON, load them and overlay them:
% Load shapefile
S = shaperead('world_boundaries.shp'); % Replace with your shapefile
% Overlay each boundary
for k = 1:length(S)
wmpolygon(S(k).Lat, S(k).Lon, 'FaceColor', 'none', 'EdgeColor', 'black');
end
- Consider creating a custom basemap with overlays baked using addCustomBasemap if you frequently use specific overlays
For more details on webmap, refer to the following documentation link:
Hope this helps.
