Display geographic marker on web map
wmmarker(
displays
marker overlay specified by the latitude and longitude data in the
geopoint vector P
)P
. Each element of P
defines
one marker overlay.
wmmarker(
displays
the overlay in the web map specified by the web map handle, wm
,___)wm
.
wmmarker(__,
specifies
name-value pairs that set additional display properties. Parameter
names can be abbreviated and are case-insensitive.Name,Value
)
returns
a handle to the overlay.h
= wmmarker(___)
Display a marker at the location of London, England. There is no current web map, so
the wmmarker
function creates one.
lat = 51.5187666404504; lon = -0.130003487285315; wmmarker(lat,lon)
wmmarker
adds the marker name to the list of overlays in the
Layer Manager. The default name is Marker Overlay 1.
Read sample feature data into a geopoint vector.
p = gpxread('boston_placenames');
Display markers at features defined in the geopoint vector. Additionally specify the
feature names and overlay names. There is no current web map, so the
wmmarker
function creates one. Click on a marker to see information
about the feature, including its name.
wmmarker(p,'FeatureName',p.Name,'OverlayName','Boston Placenames')
Define a location. For this example, specify the coordinates of MathWorks®.
lat = 42.299827; lon = -71.350273;
Specify a name and text to display in the description balloon. This code makes the MathWorks URL a link.
name = 'MathWorks'; description = sprintf(... '%s<br>%s</br><br>%s</br>',... '3 Apple Hill Drive', 'Natick, MA. 01760', ... '<a href="https://www.mathworks.com" target="_blank">https://www.mathworks.com</a>');
Specify a custom icon for the marker.
iconDir = fullfile(matlabroot,'toolbox','matlab','icons'); iconFilename = fullfile(iconDir,'matlabicon.gif');
Display the marker on the web map by using wmmarker
. Specify
the Description
, FeatureName
,
Icon
, and OverlayName
name-value pairs. Note the
custom icon. Display the text you included by clicking on the marker. Note the HTML
formatting in the description.
wmmarker(lat,lon,'Description',description, ... 'FeatureName',name, ... 'Icon',iconFilename, ... 'OverlayName',name)
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. Note that the table contains the data you specified in the attribute spec.
webmap('ocean basemap'); wmmarker(p,'Description',attribspec,... 'OverlayName','Tsunami Events') wmzoom(2)
lat
— Latitudes of pointsLatitudes of points, specified as a matrix.
Data Types: single
| double
lon
— Longitudes of pointsLongitudes of points, specified as a matrix.
Data Types: single
| double
P
— Geographic featuresGeographic features, specified as a geopoint vector.
wm
— Web mapWeb map, specified as a web map handle.[1]
Specify optional
comma-separated pairs of Name,Value
arguments. Name
is
the argument name and Value
is the corresponding value.
Name
must appear inside quotes. You can specify several name and value
pair arguments in any order as
Name1,Value1,...,NameN,ValueN
.
wmmarker(lat,lon,'Autofit',true)
'Autofit'
— Overlay visibilityOverlay visibility, specified as the comma-separated pair consisting
of 'Autofit'
and 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.
Data Types: double
| logical
'Description'
— Description of feature' '
) (default) | character vector | cell array of character vectors | scalar structureDescription of feature, specified as the comma-separated pair
consisting of 'Description'
and a character vector,
cell array of character vectors, or scalar structure. The description
defines the content that wmmarker
displays 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 HTML markup. 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
character vector (''
). 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) | character vectorName of overlay layer, specified as the comma-separated pair
consisting of 'OverlayName'
and a character vector. 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
where N
'N
is
the number assigned to this overlay.
Data Types: char
'FeatureName'
— Name of feature'OverlayName
:
Point K
'
(default) | character vector | cell array of character vectorsName of feature, specified as the comma-separated pair consisting
of 'FeatureName'
and a character vector or cell
array of character vectors. The name appears in the feature's balloon
when a user clicks on the feature in the web map. The default value
is '
,
where OverlayName
: Point K
'OverlayName
is the name of the overlay
and K
is the number assigned to a particular
point. If the value is a character vector, 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
.
Data Types: char
| cell
'Icon'
— File name of custom icon for a markerFile name of custom icon for a marker, specified as the comma-separated pair consisting of
'Icon'
and a character vector
or cell array of character vectors. If the icon
file name is not in the current folder, or in a
folder on the MATLAB® path, specify a full or relative path
name. If you specify an Internet URL it must
include the protocol type. If the icon file name 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.
Data Types: char
| cell
'IconScale'
— Scaling factor for iconScaling factor for icon, specified as the comma-separated pair
consisting of 'IconScale'
and a positive numeric
scalar or vector.
Data Types: double
'Color'
— Color of icon'red'
(default) | ColorSpec
| cell array of character vectors | M-by-3 numeric arrayColor of icon, 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. 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
.
Data Types: double
| char
| cell
'Alpha'
— Transparency of markerTransparency of marker, 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 marker,
that is, the vector must be the same length as P
.
The default value, 1
, means that the marker is
fully opaque.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
h
— Marker overlayMarker overlay, returned as a handle to a marker overlay object.
[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.