Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the page.

wmline

Display geographic line on web map

Syntax

  • wmline(lat,lon)
    example
  • wmline(P)
    example
  • wmline(wm,___)
  • wmline(___,Name,Value)
  • h = wmline(___)

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 content of the geopoint or geoshape vector 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

Find the latitude and longitude for London and Paris.

cities = shaperead('worldcities.shp', 'UseGeoCoords', true, ... 
    'Selector', ... 
    {@(v)(ismember(v, {'London', 'Paris'})), 'Name'}); 
lat = [cities.Lat]; 
lon = [cities.Lon]; 

Draw line on web map from London to Paris.

wmline(lat, lon)

Large data sets can sometimes be slow to display, making the web map browser 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.

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) 

Draw coast lines on web map. The figure shows the description balloon that appears when you click on the line. The code sets the FeatureName attribute to "coastline".

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

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

lat0 = 51.50487; 
lon0 = .05235; 

Create a web map using MapQuest OpenStreetMap layer.

webmap('MapQuestOpenStreetMap')

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); 

Draw 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 a geopoint or geoshape vector.

  • If P is a geopoint vector, the overlay contains a single line connecting its vertices.

  • If P is a geoshape vector, the overlay contains one line feature for each element of P.

Web map, specified as a web map handle.

Name-Value Pair Arguments

Specify optional comma-separated pairs of Name,Value arguments. Name is the argument name and Value is the corresponding value. Name must appear inside single quotes (' '). You can specify several name and value pair arguments in any order as Name1,Value1,...,NameN,ValueN.

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

collapse all

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 browser. 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 a MATLAB® Color Specification (ColorSpec), a cell array of color names, or a numeric array.

  • 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 line feature, that is, the cell array must be the same length as P.

  • If the value is a numeric array, it must be M-by-3, where M is either 1 or the length of P.

Data Types: double | char | cell

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.

More About

collapse all

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.

Introduced in R2013b

Was this topic helpful?