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 consisting of 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.

  • 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.

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

expand all

Draw Line on Web Map

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)

Draw Reduced Line on Web Map

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.

coast = load('coast');

Reduce length of vectors.

[lat, lon] = reducem(coast.lat, coast.long);

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

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

Draw coast line on web map.

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

Draw Circles on Web Map

This example shows how to draw lines on a web map, displaying range data for an airport approach pattern.

Assign latitude and longitude of the feature.

lat0 = 51.50487; 
lon0 = .05235; 

Create a web map using MapQuest OpenStreetMap layer.

webmap('MapQuestOpenStreetMap') 

Compute small circle for 1000 meter radius.

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

Draw red circle with 1000 meter radius.

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

Compute small circle for 2000 meter radius.

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

Draw black circle with 2000 meter radius.

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

Input Arguments

expand all

lat — Latitude valuesarray of type single or double

Latitude values, specified as an array of type single or double.

Example: lat = [42.3583 40.7142];

Data Types: single | double

lon — Longitude valuesarray of type single or double

Longitude values, specified as an array of type single or double.

Example: lon = [-71.0603 —74.0064];

Data Types: single | double

p — Geographic featuresgeopoint vector | geoshape vector

Geographic features, specified as a geopoint or geoshape vector.

Example: p = gpxread('sample_tracks', 'Index', 1:2);

wm — Web mapweb map handle

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

'Autofit' — Line visibilitytrue (default) | false

Line visibility, specified as 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.

Example: wmline(lat,lon,'Autofit',true)

Data Types: double | logical

'Description' — Description of featureempty string (default) | character string | cell array of strings | scalar structure

Description of feature, specified as a character string, cell array of strings, or a scalar structure. The description defines the content that is displayed in the feature's description balloon which appears when a user clicks on the feature in the web map. Description elements can be either plain text or marked up with HTML. When an attribute spec is provided, the display in the balloon for the attribute fields of p are modified according to the specification. The default value is an empty string.

  • If the value is a cell array, it must be either a scalar or the same length as p and specifies the description for each line.

  • If the value is a structure, the attribute spec is applied to each line.

Data Types: char | struct | cell

'OverlayName' — Name of overlay layer'Line Overlay N', (default) | text string

Name of overlay layer, specified as a text string. 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.

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

Data Types: char

'FeatureName' — Name of featureOverlayName: Line K' (default) | text string | cell array of strings

Name of feature, specified as text string or cell array of strings. The name appears in the feature's balloon when a user clicks on 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 string, it applies to all features.

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

Example: wmline(lat,lon,'FeatureName','Route 66');

Data Types: char | cell

'Color' — Line color'black' (default) | ColorSpec | cell array of strings | M-by-3 numeric array

Line color, specified as a MATLAB® Color Specification (ColorSpec), a cell array of color strings, or a numeric array.

  • If the value is a cell array, it must be scalar or the same length as p.

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

Example: wmline(lat,lon,'Color','white');

'Width' — Line width1 (default) | positive numeric scalar or vector

Line width, specified as 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.

Example: wmline(lat,lon,'Width',2);

Output Arguments

expand all

h — Overlay layerhandle to line overlay

Overlay layer, returned as a handle.

More About

expand 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 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.

Was this topic helpful?