Class 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 is EPSG:4326, also referred to as GPS coordinates. If the user projection has been changed using Map.setUserProjection(String), then coordinates must be specified in that projection instead.
    See Also:
    Serialized Form
    • 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 is EPSG:4326, also referred to as GPS coordinates. If the user projection has been changed using Map.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 constructor Coordinate(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 Projection.EPSG_3857 projection.
        Parameters:
        longitude - longitude value
        latitude - 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 constructor Coordinate(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 value
        latitude - latitude value
        targetProjection - the projection of the resulting coordinate
        Returns:
        coordinate in the specified projection