Class Coordinate
- java.lang.Object
-
- com.vaadin.flow.component.map.configuration.Coordinate
-
- All Implemented Interfaces:
Serializable
public class Coordinate extends Object implements Serializable
Represents map coordinates in a specific projection. Coordinates must be specified in the map's user projection, which by default isEPSG: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.- See Also:
- Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Coordinate()
Coordinate(double x, double y)
Constructs a new coordinate instance from x and y coordinates.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static Coordinate
fromLonLat(double longitude, double latitude)
Deprecated.Since 23.2, the default coordinate system has been changed to EPSG:4326, which allows passing latitude and longitude into the constructor directly.static Coordinate
fromLonLat(double longitude, double latitude, Projection targetProjection)
Deprecated.Since 23.2, the default coordinate system has been changed to EPSG:4326, which allows passing latitude and longitude into the constructor directly.double
getX()
double
getY()
String
toString()
-
-
-
Constructor Detail
-
Coordinate
public Coordinate()
-
Coordinate
public Coordinate(double x, double y)
Constructs a new coordinate instance from x and y coordinates. Coordinates must be specified in the map's user projection, which by default isEPSG: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.- Parameters:
x
-y
-
-
-
Method Detail
-
getX
public double getX()
-
getY
public double getY()
-
fromLonLat
@Deprecated public static Coordinate fromLonLat(double longitude, double latitude)
Deprecated.Since 23.2, the default coordinate system has been changed to EPSG:4326, which allows passing latitude and longitude into the constructor directly. Usages of this method should be replaced with a call to the constructorCoordinate(double, double)
.Since the default coordinate system has been changed to EPSG:4326, and the purpose of this method is to return coordinates in EPSG:3857, this method will not return correct results anymore. As a temporary measure, the coordinate system can be changed back to EPSG:3857 using
Map.setUserProjection(String)
. Long-term, usages of this method should be replaced.Creates a coordinate from a longitude and latitude, and converts it intoProjection.EPSG_3857
projection.- Parameters:
longitude
- longitude valuelatitude
- latitude value- Returns:
- coordinate in
Projection.EPSG_3857
projection
-
fromLonLat
@Deprecated public static Coordinate fromLonLat(double longitude, double latitude, Projection targetProjection)
Deprecated.Since 23.2, the default coordinate system has been changed to EPSG:4326, which allows passing latitude and longitude into the constructor directly. Usages of this method should be replaced with a call to the constructorCoordinate(double, double)
.Since the default coordinate system has been changed to EPSG:4326, and the purpose of this method is to return coordinates in EPSG:3857, this method will not return correct results anymore. As a temporary measure, the coordinate system can be changed back to EPSG:3857 using
Map.setUserProjection(String)
. Long-term, usages of this method should be replaced.Creates a coordinate from a longitude and latitude, and converts it into the specified projection.Currently, only converting into
Projection.EPSG_3857
projection is supported.- Parameters:
longitude
- longitude valuelatitude
- latitude valuetargetProjection
- the projection of the resulting coordinate- Returns:
- coordinate in the specified projection
-
-