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. Which projection the coordinates are in is not known by the coordinate itself, and developers must ensure themselves to use the same projection between coordinates, the map viewport, and map sources.- 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 Modifier and Type Method Description static Coordinate
fromLonLat(double longitude, double latitude)
Creates a coordinate from a longitude and latitude, and converts it intoProjection.EPSG_3857
projection.static Coordinate
fromLonLat(double longitude, double latitude, Projection targetProjection)
Creates a coordinate from a longitude and latitude, and converts it into the specified projection.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. Unless the map's view uses a custom projection, it is assumed that the coordinates are inEPSG:3857
/ Web Mercator Sphere projection. To create coordinates from latitude and longitude, seefromLonLat(double, double)
.- Parameters:
x
-y
-
-
-
Method Detail
-
getX
public double getX()
-
getY
public double getY()
-
fromLonLat
public static Coordinate fromLonLat(double longitude, double latitude)
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
public static Coordinate fromLonLat(double longitude, double latitude, Projection targetProjection)
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
-
-