Add Line, Polygon, and Marker Overlay Layers to Web Maps
This example shows how to add line, polygon, and marker overlay layers to a web map. Overlay layers can add information, such as, state borders and coast lines, to a base layer map. The toolbox includes functions to draw lines, polygons, and web markers on a web map.
For example, to draw a multifaceted line or multiple lines on a map, use the wmline
function. You use latitude and longitude values to specify the
points that define the line. Similarly, to draw a polygon, use the wmpolygon
function, specifying latitude and longitude values that define
the vertices of the polygon. You can also add markers, or map
pins, to identify points of interest on a web map using the wmmarker
function.
The following example illustrates these capabilities.
Load latitude and longitude data. This creates two variables in the workspace:
coastlat
andcoastlon
.load coastlines
Use the latitude and longitude data to define a line overlay.
wmline
draws the overlay on the current web map or, if none exists, it creates a new web map. The example includes several optional parameters to specify the line width and the name you want associated with the line.wmline(coastlat,coastlon,'LineWidth',3,'FeatureName','coastline')
The
wmline
command adds the new overlay to the list of overlays in the Layer Manager. By default, this layer is called Line Overlay 1.Use the same latitude and longitude data to define a polygon overlay.
wmpolygon
interprets the latitudes and longitudes as the vertices of a polygon, and draws the overlay on the current web map. The example includes several optional parameters to specify the line width and the name you want associated with the line.wmpolygon(coastlat,coastlon,'FeatureName','coastline','FaceColor','green')
The
wmpolygon
command adds the polygon overlay to the list of overlays in the Layer Manager. By default, this layer is called Polygon Overlay 2.Add a marker to the web map by using the
wmmarker
function. Display information about the marker by clicking on it. Thewmmarker
function adds the marker overlay to the list of overlays in the Layer Manager. By default, this layer is called Marker Overlay 3.wmmarker(10.5000,-66.8992,'FeatureName','Caracas')
See Also
webmap
| wmline
| wmpolygon
| wmmarker
| wmremove