Class MapView

  • All Implemented Interfaces:
    Styleable, EventTarget, Skinnable

    public final class MapView
    extends GeoView
    A MapView renders data from an ArcGISMap and allows users to interact with the map. In an MVC architecture, a MapView represents the view and an ArcGISMap represents the model. This class must only be created and used on the UI thread. A MapView cannot be used after it has been disposed.
    Since:
    100.0.0
    See Also:
    ArcGISMap
    • Constructor Detail

      • MapView

        public MapView()
        Creates a new MapView instance.
        Since:
        100.0.0
    • Method Detail

      • getSpatialReference

        public SpatialReference getSpatialReference()
        Gets the spatial reference.
        Specified by:
        getSpatialReference in class GeoView
        Returns:
        the spatial reference, null if the ArcGISMap is null
        Since:
        100.0.0
      • getWrapAroundMode

        public WrapAroundMode getWrapAroundMode()
        Gets the wrap around mode.

        If a map is in wrap around mode then you can pan across the international date line if your BaseMap is in a suitable SpatialReference

        Returns:
        the wrap around mode
        Since:
        100.0.0
      • setWrapAroundMode

        public void setWrapAroundMode​(WrapAroundMode wrapAroundMode)
        Sets the wrap around mode.

        If a map is in wrap around mode then you can pan across the international date line if your BaseMap is in a suitable SpatialReference

        Parameters:
        wrapAroundMode - the new wrap around mode
        Since:
        100.0.0
      • getMapScale

        public double getMapScale()
        Gets the scale.
        Returns:
        the scale
        Since:
        100.0.0
      • getMapRotation

        public double getMapRotation()
        Gets the map rotation.
        Returns:
        the map rotation in degrees.
        Since:
        100.0.0
      • getBackgroundGrid

        public BackgroundGrid getBackgroundGrid()
        Gets the BackgroundGrid set on the MapView.
        Returns:
        the BackgroundGrid currently set on the MapView
        Since:
        100.0.0
      • setBackgroundGrid

        public void setBackgroundGrid​(BackgroundGrid backgroundGrid)
        Sets the desired BackgroundGrid on the MapView.
        Parameters:
        backgroundGrid - the BackgroundGrid to be applied to the MapView
        Throws:
        IllegalArgumentException - if the backgroundGrid is null
        Since:
        100.0.0
      • getUnitsPerDensityIndependentPixel

        public double getUnitsPerDensityIndependentPixel()
        Gets the map units per density-independent pixel(dp).
        Returns:
        the map units per density-independent pixel(dp)
        Since:
        100.0.0
      • getVisibleArea

        public Polygon getVisibleArea()
        Gets the visible area of the map view.
        Returns:
        the visible area
        Since:
        100.0.0
      • setViewpointAsync

        public ListenableFuture<Boolean> setViewpointAsync​(Viewpoint viewpoint,
                                                           float durationSeconds,
                                                           AnimationCurve animationCurve)
        Set viewpoint asynchronously taking the given number of seconds to complete and using the supplied AnimationCurve to define the easing function for the animation.
        Parameters:
        viewpoint - the viewpoint being animated to
        durationSeconds - the duration of the animation in seconds
        animationCurve - the animation curve to apply
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Throws:
        IllegalArgumentException - if viewpoint is null
        IllegalArgumentException - if animationCurve is null
        Since:
        100.1.0
      • setViewpointCenterAsync

        public ListenableFuture<Boolean> setViewpointCenterAsync​(Point point)
        Sets the viewpoint center asynchronously.
        Parameters:
        point - the new viewpoint center
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Throws:
        NullPointerException - if argument is null
        Since:
        100.0.0
      • setViewpointGeometryAsync

        public ListenableFuture<Boolean> setViewpointGeometryAsync​(Geometry boundingGeometry)
        Sets the viewpoint geometry asynchronously.
        Parameters:
        boundingGeometry - the new viewpoint geometry
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Throws:
        NullPointerException - if the argument is null
        Since:
        100.0.0
      • setViewpointGeometryAsync

        public ListenableFuture<Boolean> setViewpointGeometryAsync​(Geometry boundingGeometry,
                                                                   double padding)
        Set viewpoint geometry with padding asynchronously.
        Parameters:
        boundingGeometry - the bounding geometry
        padding - the padding
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Throws:
        NullPointerException - if the bounding geometry is null
        Since:
        100.0.0
      • setViewpointRotationAsync

        public ListenableFuture<Boolean> setViewpointRotationAsync​(double angleDegrees)
        Sets the viewpoint rotation asynchronously.
        Parameters:
        angleDegrees - the new viewpoint rotation
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Since:
        100.0.0
      • setViewpointScaleAsync

        public ListenableFuture<Boolean> setViewpointScaleAsync​(double scale)
        Sets the viewpoint scale asynchronously.
        Parameters:
        scale - the new viewpoint scale
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Since:
        100.0.0
      • setViewpointCenterAsync

        public ListenableFuture<Boolean> setViewpointCenterAsync​(Point center,
                                                                 double scale)
        Set viewpoint center with scale asynchronously.
        Parameters:
        center - the center
        scale - the scale
        Returns:
        a ListenableFuture. Add a listener to this to know when the viewpoint has finished animating. The result of the future indicates if the operation completed successfully or not.
        Throws:
        NullPointerException - if the center is null
        Since:
        100.0.0
      • getMap

        public ArcGISMap getMap()
        Gets the ArcGISMap shown in this MapView.
        Returns:
        the ArcGISMap
        Since:
        100.0.0
      • setMap

        public void setMap​(ArcGISMap map)
        Sets the ArcGISMap to be displayed in this view. Null is allowed.
        Parameters:
        map - the new ArcGISMap
        Since:
        100.0.0
      • locationToScreen

        public Point2D locationToScreen​(Point mapPoint)
        Converts a Point in map coordinates to a javafx.geometry.Point2D representing device screen coordinates. Coordinate values are in pixels, relative to the top-left corner of the MapView's screen location.

        Use this method to help perform custom drawing, or to locate other user interface components, relative to specific map coordinates. For example, calculate the screen coordinates at which to show a button so that it displays adjacent to a specific feature or raster cell in the map.

        This method will attempt to convert any coordinates within the MapView's SpatialReference, and therefore can result in coordinates outside the actual screen bounds. For example if a map of the world is zoomed in to the extent of Africa, a map location within South America would result in a point off screen.

        If wrap around is enabled, then the map is drawn as continuous horizontal repeats, allowing you to pan continuously - this means that one map location could relate to multiple potential screen locations. In this case, if the map location lies within the screen bounds then that location is used; otherwise the location closest to the center of the view is used.

        Parameters:
        mapPoint - the map point
        Returns:
        an javafx.geometry.Point2D representing screen coordinates in pixels.
        Throws:
        IllegalArgumentException - if mapPoint is null
        Since:
        100.0.0
      • screenToLocation

        public Point screenToLocation​(Point2D screenPoint)
        Converts a screen point to a map point.
        Parameters:
        screenPoint - the screen point
        Returns:
        the map point
        Throws:
        IllegalArgumentException - if screenPoint is null
        Since:
        100.0.0
      • setViewInsets

        public void setViewInsets​(Insets viewInsets)
        Sets the specified insets on the view.

        Units are specified in density-independent pixels (DIPs)

        Parameters:
        viewInsets - insets to be set on the view, can be null. If null, the insets will be set to empty.
        Since:
        100.1.0
        See Also:
        viewInsetsProperty()
      • viewInsetsProperty

        public ObjectProperty<Insets> viewInsetsProperty()
        Returns the insets on the view.

        Insets are useful to shift UI controls (such as license string, callout, etc) which are overlaid on the view. An application may need to do this shift to make room for application specific controls.

        It also effects the reported visible area, which will now be the area of the view minus the area of the insets.

        Insets may be invalidated when the view is resized. If the insets are bigger than the view size, they are ignored.

        Since:
        100.1.0
        See Also:
        isViewInsetsValid()
      • getViewInsets

        public Insets getViewInsets()
        Gets the insets on the view.
        Returns:
        the insets
        Since:
        100.1.0
      • isViewInsetsValid

        public boolean isViewInsetsValid()
        Indicates whether the insets specified on the view are currently valid. It can be used to check whether the insets are valid after the view is resized.
        Returns:
        true if the insets are smaller than the current view size; false if they are equal to or larger
        Since:
        100.1.0
      • addMapRotationChangedListener

        public void addMapRotationChangedListener​(MapRotationChangedListener listener)
        Adds a listener for when map rotation has changed.
        Parameters:
        listener - the listener
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0
      • removeMapRotationChangedListener

        public boolean removeMapRotationChangedListener​(MapRotationChangedListener listener)
        Removes a map rotation changed listener.
        Parameters:
        listener - the listener
        Returns:
        true, if successful
        Since:
        100.0.0
      • addMapScaleChangedListener

        public void addMapScaleChangedListener​(MapScaleChangedListener listener)
        Adds a listener for when map scale has changed.
        Parameters:
        listener - the listener
        Throws:
        IllegalArgumentException - if the listener is null
        Since:
        100.0.0
      • removeMapScaleChangedListener

        public boolean removeMapScaleChangedListener​(MapScaleChangedListener listener)
        Removes a map scale changed listener.
        Parameters:
        listener - the listener
        Returns:
        true, if successful
        Since:
        100.0.0
      • setSketchEditor

        public void setSketchEditor​(SketchEditor sketchEditor)
        Sets the Sketch Editor.
        Parameters:
        sketchEditor - a sketch editor, can be null
        Since:
        100.1.0
        See Also:
        SketchEditor
      • getSketchEditor

        public SketchEditor getSketchEditor()
        Gets the current Sketch Editor, or null if not set.
        Returns:
        the current sketch editor, or null if not set
        Since:
        100.1.0
      • setGrid

        public void setGrid​(Grid grid)
        Sets a grid to be displayed on top of the MapView.

        If a developer wants to temporarily hide the grid, they can change the grid's visibility. Setting a grid to not visible will hide the grid and its labels. This method should be used in preference to setting the grid to null, which is an expensive operation.

        Parameters:
        grid - grid to display on top of the MapView, can be null
        Since:
        100.0.0
        See Also:
        getGrid(), Grid.setVisible(boolean), LatitudeLongitudeGrid, MgrsGrid, UsngGrid, UtmGrid
      • getLabeling

        public ViewLabelProperties getLabeling()
        Gets the labeling properties. The ViewLabelProperties denote whether labels and label animation are enabled or not.
        Returns:
        the label properties
        Since:
        100.4.0
      • setLabeling

        public void setLabeling​(ViewLabelProperties viewLabelProperties)
        Sets labeling properties. The ViewLabelProperties can be used to enable or disable labels and label animation.
        Parameters:
        viewLabelProperties - the label properties to set
        Throws:
        IllegalArgumentException - if viewLabelProperties is null
        Since:
        100.4.0