Class View

    • 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 than EPSG:3857 / Web Mercator Sphere projection.
        Parameters:
        projection - the custom coordinate projection to use
    • Method Detail

      • 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 to 28. 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 projection
        Returns:
        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 coordinates
        rotation - the updated rotation
        zoom - the updated zoom level
        extent - the updated extent