com.vaadin.flow.component.map.configuration.
Class View
All Implemented Interfaces:
Represents a map's viewport, responsible for changing properties like center and zoom level
See Also:
-
Field Summary
Fields inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
propertyChangeSupport
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionGets center coordinates of the view
Gets the extent (or bounding box) of the view's currently visible area.
Gets the projection of the view, which defaults to
EPSG:3857
/ Web Mercator Sphere projectiondouble
Get rotation of the view, defaults to
0
getType()
The unique type name of this class.
double
getZoom()
Gets zoom level of the view, defaults to
0
void
setCenter
(Coordinate center) Sets the center of the map's viewport.
void
setRotation
(double rotation) Sets the rotation of the view in radians
void
setZoom
(double zoom) Sets the zoom level of the view.
void
updateInternalViewState
(Coordinate center, double rotation, double zoom, Extent extent) Updates internal state of view to the latest values received from client.
Methods inherited from class com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
addChild, addNullableChild, addPropertyChangeListener, collectChanges, deepMarkAsDirty, getId, markAsDirty, notifyChange, notifyChange, removeChild, removePropertyChangeListener, setId, update
-
Constructor Details
-
View
public View()Constructs a new view using
EPSG:3857
/ Web Mercator Sphere coordinate projection by default. Unless you are using a custom map service that uses a different projection, this is what you want. -
View
Constructs a new view using a custom coordinate projection. A custom view projection is only necessary when using a map service and corresponding
Source
that uses a projection other thanEPSG:3857
/ Web Mercator Sphere projection.Parameters:
projection
- the custom coordinate projection to use
-
-
Method Details
-
getType
Description copied from class:
AbstractConfigurationObject
The unique type name of this class. Used by the client-side synchronization mechanism to determine which OpenLayers class to synchronize into.
Specified by:
getType
in classAbstractConfigurationObject
-
getCenter
Gets center coordinates of the view
Returns:
center of the view
-
setCenter
Sets the center of the map's viewport. Coordinates must be specified in the map's user projection, which by default is
EPSG:4326
, also referred to as GPS coordinates. If the user projection has been changed usingMap.setUserProjection(String)
, then coordinates must be specified in that projection instead.Note that the user projection is a different concept than the view projection set in this view. The view projection affects how map data is interpreted and rendered, while the user projection defines the coordinate system that all coordinates passed to, or returned from the public API must be in.
Parameters:
center
- coordinates of the center of the view -
getRotation
public double getRotation()Get rotation of the view, defaults to
0
Returns:
current rotation in radians
-
setRotation
public void setRotation(double rotation) Sets the rotation of the view in radians
Parameters:
rotation
- the rotation in radians format -
getZoom
public double getZoom()Gets zoom level of the view, defaults to
0
Returns:
current zoom level
-
setZoom
public void setZoom(double zoom) Sets the zoom level of the view. The zoom level is a decimal value that starts at
0
as the most zoomed-out level, and then continually increases to zoom further in. By default, the maximum zoom level is currently restricted to28
. In practical terms, the level of detail of the map data that a map service provides determines how useful higher zoom levels are.Parameters:
zoom
- new zoom level -
getProjection
Gets the projection of the view, which defaults to
EPSG:3857
/ Web Mercator Sphere projectionReturns:
the projection of the view
-
getExtent
Gets the extent (or bounding box) of the view's currently visible area. Can be used to check whether a specific coordinate is within the viewport.
NOTE: The extent is calculated on the client-side and will only be available after the first view change event.
Returns:
the coordinates of the view's extent
-
updateInternalViewState
Updates internal state of view to the latest values received from client.
For internal use only.
Parameters:
center
- the updated center coordinatesrotation
- the updated rotationzoom
- the updated zoom levelextent
- the updated extent
-