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.

  1. Load latitude and longitude data. This creates two variables in the workspace: coastlat and coastlon.

    load coastlines
    
  2. 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')
    

  3. The wmline command adds the new overlay to the list of overlays in the Layer Manager.

  4. 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')
    

  5. The wmpolygon command adds the polygon overlay to the list of overlays in the Layer Manager.

  6. Add a marker to the web map, using the wmmarker function. wmmarker adds the marker overlay to the list of overlays in the Layer Manager.

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

See Also

| | | |

Related Topics