Main Content

Remove Overlay Layers on a Web Map

To remove an overlay layer on a web map, use the wmremove function. When called without an argument, wmremove deletes the most recently added overlay layer. You can also remove a particular overlay by specifying the handle of the line or marker overlay. The following example illustrates this capability.

  1. Load latitude and longitude data. This command loads two variables into the workspace: coastlat and coastlon.

    load coastlines
    
  2. Add a line overlay of the coastline data and set the overlay to a variable using the wmline function. There is no current web map, so wmline creates one.

    h = wmline(coastlat,coastlon,'Width',3,'FeatureName','coastline');
    

    Web map with global coastlines outlined in black

  3. Add a marker overlay and set it to a variable using the wmmarker function. The marker highlights the location of the city of Caracas. Note that the overlays are listed in the Layer Manager as Line Overlay 1 and Marker Overlay 2.

    h2 = wmmarker(10.5000,-66.8992,'FeatureName','Caracas');
    

    Web map and Layer Manager with line and marker overlays

  4. Remove one of the overlays by using the wmremove function. When called without an argument, wmremove deletes the most recent overlay. In this case, wmremove removes the marker overlay. The wmremove function also removes the marker entry in the Layer Manager.

    wmremove
    

    Web map and Layer Manager without marker overlay

  5. Remove a particular overlay by specifying it when you call wmremove. For example, remove the line overlay.

    wmremove(h)
    

    Web map and Layer Manager without line overlay

See Also

| | | |

Related Topics