Adjusts the maps visible region to bring the specified overlays and annotations into view.
- MapKit JS 5.0+
An array of annotations and/or overlays to make visible.
Options defined by
Mapthat let you determine animation, padding, and the minimum span.
Show Items Options
Returns the items array that was passed in.
Adjusts the map's
region to bring the specified items into view. An item is an annotation or overlay. The items are added to the map if they are not already in the map.
The region will cover the smallest longitudinal span possible. For example, consider an array of items that consists of two annotations for the cities Tokyo and Los Angeles, and a polyline that represents the flight path between them. The region chosen will cover the Pacific Ocean rather than North America, the Atlantic Ocean, Europe and Asia.
In deciding how much to show, this method takes the actual pixel size of the items into account. For example, even though an annotation represents a point, the annotation itself occupies space. This method ensures that the entirety of an annotation is visible in the map. Similarly, this method ensures that an overlay with thick lines is shown in its entirety.
However, in some cases it is possible that not all items can be shown at once, or the actual padding does not match the requested padding. This happens if:
One or more items falls outside of the visible map region that can be displayed, even at the minimum zoom level.
The amount of padding is determined by the zoom level, which always snaps to an integral zoom level and may have a different amount of padding than requested.
This method throws an Error if the arguments to the method are invalid.