Main Content

wmline

Display geographic line on web map

Description

example

wmline(lat,lon) displays a line overlay defined by the vertices in lat,lon on the current web map. If there is no current web map, wmline creates one. wmline centers the map so that all vector overlays displayed on the web map are visible.

example

wmline(P) displays a line overlay based on the vector geographic features stored in P.

wmline(wm,___) displays the line overlay on the web map specified by the web map handle, wm.

wmline(___,Name,Value) specifies name-value pairs that set additional display properties.

h = wmline(___) returns a handle to line overlay.

Examples

collapse all

Import a shapefile containing the coordinates of world cities as a geospatial table. Create a subtable containing the rows for London and Paris.

cities = readgeotable("worldcities.shp");
rows = cities.Name == "London" | cities.Name == "Paris";
londonParis = cities(rows,:);

Display a line from London to Paris on a web map.

wmline(londonParis) 

Large data sets can sometimes be slow to display, making the web map appear to hang. To work around this issue, reduce the size of the data set using the reducem function before calling wmline.

Load vector data representing the coordinates of coastlines.

load coastlines

Reduce the number of points in the latitude and longitude vectors using the reducem function.

[lat,lon] = reducem(coastlat,coastlon);

Create a web map that does not wrap because the data is of global extent.

webmap('ocean basemap','WrapAround',false)

Display the coastlines on the web map. The figure shows the description balloon that appears when you click on the line. Name the feature using the 'FeatureName' name-value pair.

wmline(lat,lon,'LineWidth',3,'FeatureName','coastline')
wmzoom(3)

Define the latitude and longitude of the feature. This example shows how to display lines on a web map that represent range data for an airport approach pattern.

lat0 = 51.50487; 
lon0 = 0.05235; 

Create a web map and specify a base layer.

webmap('OpenStreetMap')

Compute a small circle with a 1000 meter radius. Setting the az parameter to an empty matrix causes scircle1 to compute a complete circle.

radius = 1000; 
az = []; 
e = wgs84Ellipsoid; 
[lat,lon] = scircle1(lat0,lon0,radius,az,e); 

Display a red circle with 1000 meter radius, using the latitude and longitude values returned by scircle1 in the previous step.

wmline(lat,lon,'Color','red','OverlayName','1000 Meters')

Compute another small circle, this time with a 2000 meter radius.

radius = 2000; 
[lat,lon] = scircle1(lat0,lon0,radius,az,e);

Draw the 2000 meter radius circle on the web map, setting the color to black.

wmline(lat,lon,'Color','k','OverlayName','2000 Meters')

Input Arguments

collapse all

Latitudes of vertices, specified as a matrix.

Data Types: single | double

Longitudes of vertices, specified as a matrix.

Data Types: single | double

Geographic features, specified as one of the following:

  • A geospatial table containing geopointshape, geolineshape, or geopolyshape objects. The wmline function does not support geospatial tables containing more than one type of shape object. For more information about geospatial tables, see Create Geospatial Tables.

  • A geopoint vector.

  • A geoshape vector.

If P is a geospatial table containing geopointshape objects or a geopoint vector, then the overlay contains a single line connecting the vertices.

If P is a geospatial table containing geolineshape or geopolyshape objects, or a geoshape vector, then the overlay contains one line feature for each feature of P.

Web map, specified as a web map handle.1

Name-Value Arguments

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: wmline(lat,lon,'OverlayName','Shortest Route');

Overlay visibility, specified as the comma-separated pair consisting of 'Autofit' and the scalar logical or numeric value true (1) or false (0).

  • If true, wmline adjusts the spatial extent of the map to ensure that all the vector overlays on the map are visible.

  • If false, wmline does not adjust the spatial extent when this vector layer is added to the map.

Data Types: double | logical

Description of feature, specified as the comma-separated pair consisting of 'Description' and a character vector, cell array of character vectors, or a scalar structure. The description defines the content of the description balloon displayed when you click the feature in a web map. Description elements can be either plain text or HTML markup. When an attribute spec is provided, the display in the balloon for the attribute fields of P are modified according to the specification.

  • If you specify a scalar cell array, wmline applies the value to all line features.

  • If you specify a nonscalar cell array, the cell array must contain a value for each feature, that is, the cell array must be the same length as P.

  • If the value is a structure, wmline applies the attribute specification to each line.

Data Types: char | struct | cell

Name of overlay layer, specified as the comma-separated pair consisting of 'OverlayName' and a character vector. wmline inserts the name in the Layer Manager under the "Overlays" item. The Layer Manager is the tool that appears on the right side of the web map. The default name is 'Line Overlay N' where N is the number assigned to this overlay.

Data Types: char

Name of feature, specified as the comma-separated pair consisting of 'FeatureName' and character vector or cell array of character vectors. The name appears in the balloon that displays when you click the feature in the web map. The default value is 'OverlayName : Line K', where OverlayName is the name of the overlay and K is the number assigned to the particular line.

  • If the value is a character vector, it applies to all features.

  • If the value is a cell array of character vectors, it must be either a scalar or the same length as P.

Data Types: char | cell

Line color, specified as the comma-separated pair consisting of 'Color' and one of these options.

  • A color name such as 'red' or a short name such as 'r'.

  • An RGB triplet, which is a three-element row vector whose elements specify the intensities of the red, green, and blue components of the color. The intensities must be in the range [0,1]; for example, [0.4 0.6 0.7].

  • A cell array of color names such as {'red','green','blue'} or {'r','g','b'}.

  • A string vector of color names such as ["red" "green" "blue"] or ["r" "g" "b"].

  • A matrix of RGB triplets, which is a three-column matrix in which each row is an RGB triplet.

The way you specify the color depends on the desired color scheme.

  • To apply the same color to all lines in P, specify a single color name or RGB triplet.

  • To apply a different color to each line in P, specify a cell array of color names, a string vector of color names, or a matrix of RGB triplets. The number of colors and RGB triplets must match the length of P.

This table contains the color names and equivalent RGB triplets for some common colors.

Color NameShort NameRGB TripletAppearance
"red""r"[1 0 0]

Sample of the color red

"green""g"[0 1 0]

Sample of the color green

"blue""b"[0 0 1]

Sample of the color blue

"cyan" "c"[0 1 1]

Sample of the color cyan

"magenta""m"[1 0 1]

Sample of the color magenta

"yellow""y"[1 1 0]

Sample of the color yellow

"black""k"[0 0 0]

Sample of the color black

"white""w"[1 1 1]

Sample of the color white

Data Types: char | string | cell | double

Width of line in pixels, specified as the comma-separated pair consisting of LineWidth and a positive numeric scalar or vector. If you specify a vector, it must include a value for each line, that is, the vector must be the same length as P.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Transparency of line, specified as the comma-separated pair consisting of 'Alpha' and a numeric scalar or vector. If you specify a vector, it must include a value for each line, that is, the vector must be the same length as P. The default value, 1, means that the line is fully opaque.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

Output Arguments

collapse all

Overlay layer, returned as a handle to a line overlay.

Tips

  • Under certain conditions, when you zoom in on a line overlay in a web map, parts of the line may become invisible. This can occur if the data is one long line segment that is composed of many parts. To workaround this issue, break the long line into a series of line segments by inserting NaNs in the line data.

Version History

Introduced in R2013b

expand all


1 Alignment of boundaries and region labels are a presentation of the feature provided by the data vendors and do not imply endorsement by MathWorks®.