wmmarker

Display geographic marker on web map

Syntax

  • wmmarker(lat,lon) example
  • wmmarker(p) example
  • wmmarker(wm,___)
  • wmmarker(__,Name,Value) example
  • h = wmmarker(___)

Description

example

wmmarker(lat,lon) displays a marker overlay consisting of the points in lat and lon. The overlay appears on the current web map, or if there is no current web map, wmmarker creates one. wmmarker centers the map so that all vector overlays on the web map are visible.

example

wmmarker(p) displays a marker overlay based on the content of the geopoint vector p. The overlay contains one point for each element of p.

wmmarker(wm,___) displays the overlay in the web map specified by the web map handle, wm.

example

wmmarker(__,Name,Value) specifies name-value pairs that set additional display properties. Parameter names can be abbreviated and are case-insensitive.

h = wmmarker(___) returns a handle to the overlay.

Examples

expand all

Draw Marker on Web Map

Add a marker positioned at London, England. In the illustration, note the default marker name and overlay name.

lat = 51.5187666404504;
lon = -0.130003487285315;
wmmarker(lat, lon);

Draw Markers at Features Defined in a geopoint Vector

Read feature data into geopoint vector.

p = gpxread('boston_placenames');

Draw markers at features defined in geopoint vector. wmmarker creates the web map. In the illustration, note the feature name in the balloon and the overlay name in the Layer Manager, which were specified in the call to wmmarker.

wmmarker(p, 'FeatureName', p.Name, 'OverlayName', 'Boston Placenames')

Draw Marker Using Custom Icon and Description Data

Define location.

lat =  42.299827;
lon = -71.350273;

Specify text in description balloon and name.

description = sprintf('%s<br>%s</br><br>%s</br>',...
                      '3 Apple Hill Drive', 'Natick, MA. 01760', ...
                      'http://www.mathworks.com');
 name = 'The MathWorks, Inc.';

Specify custom icon.

iconDir = fullfile(matlabroot,'toolbox','matlab','icons');
iconFilename = fullfile(iconDir, 'matlabicon.gif');

Draw marker on web map, specifying Description, FeatureName, Icon, and OverlayName. wmmarker creates the web map. In the illustration, note the custom icon and the HTML formatting in the description.

wmmarker(lat, lon, 'Description', description, ...
                   'FeatureName', name,... 
                   'Icon', iconFilename,... 
                   'OverlayName', name);

Draw Marker Overlay Using Attribute Spec

Import a shapefile representing tsunami (tidal wave) events reported over several decades, tagged geographically by source location.

S = shaperead('tsunamis', 'UseGeoCoords', true);

Convert the geostruct returned by shaperead into a geopoint vector.

p = geopoint(S);

Create an attribute spec and modify it to define a table of values to display in the feature balloon, including year, cause, country, location, and maximum height. The attribute spec defines the format of the expected value for each field.

attribspec = makeattribspec(p);

desiredAttributes = ...
       {'Max_Height', 'Cause', 'Year', 'Location', 'Country'};
allAttributes = fieldnames(attribspec);
attributes = setdiff(allAttributes, desiredAttributes);
attribspec = rmfield(attribspec, attributes);
attribspec.Max_Height.AttributeLabel = '<b>Maximum Height</b>';
attribspec.Max_Height.Format = '%.1f Meters';
attribspec.Cause.AttributeLabel = '<b>Cause</b>';
attribspec.Year.AttributeLabel = '<b>Year</b>';
attribspec.Year.Format = '%.0f';
attribspec.Location.AttributeLabel = '<b>Location</b>';
attribspec.Country.AttributeLabel = '<b>Country</b>';

Create a web map, specifying the base layer. Then add the marker overlay. In the illustration, note the table containing the data you specified in the attribute spec.

webmap('ocean basemap', 'WrapAround', false);
wmmarker(p, 'Description', attribspec,... 
	           'OverlayName', 'Tsunami Events')
wmzoom(2)

Input Arguments

expand all

lat — Latitude of pointsmatrix of type single or double

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

Example: lat = [42.3583 40.7142];

Data Types: single | double

lon — Longitude of pointsmatrix of type single or double

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

Example: lon = [-71.0603 —74.0064];

Data Types: single | double

p — Geographic featuresgeopoint vector

Geographic features, specified as a geopoint vector.

Example: p = gpxread('boston_placenames');

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: wmmarker(lat,lon,'Autofit',true)

'Autofit' — Overlay visibilitytrue (default) | false

Overlay visibility, specified as the logical flag true or false, or the numeric value 1 or 0. If true or 1, wmmarker adjusts the spatial extent of the map to ensure that all the vector overlays on the map are visible. If false, wmmarker does not adjust the spatial extent when the overlay is added to the map.

Overlay visibility, specified as a scalar logical or numeric value true (1) or false (0).

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

  • If false, wmmarker does not adjust the spatial extent when the overlay is added to the map.

Example: wmmarker(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 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 you specify an attribute spec, 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 structure, the attribute spec is applied to the attributes of each feature of p and ignored with lat and lon input.

  • If the value is a cell array it is either scalar or the same length as p, or lat and lon, and specifies the description for each marker.

  • If the value is a structure, the attribute spec is applied to the attributes of each feature of p and ignored with lat and lon input.

Data Types: char | struct | cell

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

Name of overlay layer, specified as a text string. wmmarker 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 frame. The default name is 'Marker Overlay N' where N is the number assigned to this overlay.

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

Data Types: char

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

Name of feature, specified as a 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 : Point K', where OverlayName is the name of the overlay and K is the number assigned to a particular point. If the value is a string, wmmarker applies it to all features. If the value is a cell array, it must be a scalar or an array with the same length as p or lat and lon.

Example: wmmarker(lat,lon,'FeatureName','Mt.Ranier');

Data Types: char | cell

'Icon' — File name of custom icon for a markertext string | cell array of strings

File name of custom icon for a marker, specified as a text string or cell array of strings. If the icon filename is not in the current folder, or in a folder on the MATLAB® path, specify a full or relative pathname. The string may be an Internet URL, which must include the protocol type. If the icon filename is not specified, the default icon is displayed. For best results when you want to view a non-default icon, specify a PNG file containing image data with an alpha mask.

  • If the value is a string, wmmarker applies the value to all markers.

  • If you specify a cell array, it must be the same length as p, or lat and lon, and specifies the icon for each marker.

Data Types: char | cell

'IconScale' — Scaling factor for icon1 (default) | positive numeric scalar or vector.

Scaling factor for icon, specified as a positive numeric scalar or vector.

  • If the value is a scalar, the value is applied to all icons.

  • If the value is a vector, it must specify a value for each icon, and it must be the same length as lat and lon or p.

Data Types: double

'Color' — Color of icon'red' (default) | ColorSpec | cell array of strings | M-by-3 numeric array

Color of icon, specified as a MATLAB Color Specification (ColorSpec), a cell array of color strings, or a numeric array. The color is applied to the icon when a custom icon file has not been specified, otherwise it is ignored. The default value is 'red'. If the value is a cell array, it must be the same length as LAT and LON, or P. If the value is a numeric array, it must be 1-by-3 or M-by-3 where M is the length of lat and lon or p.

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

Output Arguments

expand all

h — Handle to marker overlayscalar

Handle to marker overlay, returned as a scalar.

Was this topic helpful?