Main Content

wmcenter

Set or obtain web map center point

Description

wmcenter(centerLatitude,centerLongitude) centers the current web map at the specified latitude and longitude. If there is no current web map, wmcenter creates a new web map.

example

wmcenter(wm,centerLatitude,centerLongitude) centers the web map, specified by the handle wm, at the specified latitude and longitude.

example

wmcenter(___,zoomLevel) centers and zooms the web map to the specified zoom level.

[lat,lon] = wmcenter() returns the latitude and longitude of the center point of the current web map.

example

[lat,lon] = wmcenter(wm) returns the latitude and longitude of the center point of the web map specified by the handle wm.

Examples

collapse all

Display a web map and find its center point. There is no current web map, so wmcenter creates one.

[centerLatitude,centerLongitude] = wmcenter()
centerLatitude = 51.5200
centerLongitude = 0

Center the map at a specified center point.

wmcenter(51.52,0)

Create two web maps.

wm1 = webmap('OpenStreetMap');
wm2 = webmap('USGSImagery');

Specify the latitude and longitude for the web map center, as well as a zoom level. Then, center the web maps.

centerLatitude = 36.1;
centerLongitude = -113.2;
zoomLevel = 10;
wmcenter(wm1,centerLatitude,centerLongitude,zoomLevel)
wmcenter(wm2,centerLatitude,centerLongitude,zoomLevel)

Input Arguments

collapse all

Latitude of center point, specified as a scalar in the range [-90 90] of type single or double.

Data Types: single | double

Longitude of center point, specified as a scalar in the range [-180 180] of type single or double.

Data Types: single | double

Web map, specified as a web map handle.1

Zoom level, specified as a scalar numeric integer in the range [0 18] of type single or double.

Data Types: single | double

Output Arguments

collapse all

Latitude of center point, returned as a scalar in the range [-90 90] of type single or double.

Data Types: single | double

Longitude of center point, returned as a scalar in the range [-180 180] of type single or double.

Data Types: single | double

Tips

  • Particular maps may not support every available zoom level. If your map displays as completely white, try another zoom level. The map you are displaying may not support the zoom level you have currently selected. You can also select another base layer, which might support the specified zoom level.

Version History

Introduced in R2013b


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