com.vaadin.flow.component.map.configuration.
Class View
- java.lang.Object
-
- com.vaadin.flow.component.map.configuration.AbstractConfigurationObject
-
- com.vaadin.flow.component.map.configuration.View
-
All Implemented Interfaces:
public class View extends AbstractConfigurationObject
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
-
-
Method Summary
All Methods Modifier and Type Method Description Coordinate
getCenter()
Gets center coordinates of the view
Extent
getExtent()
Gets the extent (or bounding box) of the view's currently visible area.
String
getProjection()
Gets the projection of the view, which defaults to
EPSG:3857
/ Web Mercator Sphere projectionfloat
getRotation()
Get rotation of the view, defaults to
0
String
getType()
The unique type name of this class.
float
getZoom()
Gets zoom level of the view, defaults to
0
void
setCenter(Coordinate center)
Sets the center of the view in format specified by projection set on the view, which defaults to
EPSG:3857
void
setRotation(float rotation)
Sets the rotation of the view in radians
void
setZoom(float zoom)
Sets the zoom level of the view.
void
updateInternalViewState(Coordinate center, float rotation, float 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, addPropertyChangeListener, collectChanges, deepMarkAsDirty, getId, markAsDirty, notifyChange, notifyChange, removeChild, removePropertyChangeListener, setId, update
-
-
-
-
Constructor Detail
-
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
public View(String projection)
Constructs a new view using a custom coordinate projection. A custom 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 Detail
-
getType
public String 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
public Coordinate getCenter()
Gets center coordinates of the view
Returns:
center of the view
-
setCenter
public void setCenter(Coordinate center)
Sets the center of the view in format specified by projection set on the view, which defaults to
EPSG:3857
Parameters:
center
- coordinates of the center of the view
-
getRotation
public float getRotation()
Get rotation of the view, defaults to
0
Returns:
current rotation in radians
-
setRotation
public void setRotation(float rotation)
Sets the rotation of the view in radians
Parameters:
rotation
- the rotation in radians format
-
getZoom
public float getZoom()
Gets zoom level of the view, defaults to
0
Returns:
current zoom level
-
setZoom
public void setZoom(float 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
public String getProjection()
Gets the projection of the view, which defaults to
EPSG:3857
/ Web Mercator Sphere projectionReturns:
the projection of the view
-
getExtent
public Extent 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
public void updateInternalViewState(Coordinate center, float rotation, float zoom, Extent extent)
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
-
-