Class MapImageOverlay

java.lang.Object
com.here.NativeBase
com.here.sdk.mapview.MapImageOverlay

public final class MapImageOverlay extends NativeBase

MapImageOverlay is used to draw images over the map, at a view coordinate inside the map viewport.

The image to be displayed is represented by a MapImage object. By default, the overlay is centered on the given view coordinate.

The resulting viewport area covered by the overlay is computed out of the overlay's view coordinate, the anchor point and the image size. The overlay subareas that fall outside of the map viewport get clipped.

To display the map overlay, it needs to be added to the scene using MapScene.addMapImageOverlay(com.here.sdk.mapview.MapImageOverlay). To stop displaying it, remove it from the scene using MapScene.removeMapImageOverlay(com.here.sdk.mapview.MapImageOverlay).

  • Constructor Details

    • MapImageOverlay

      public MapImageOverlay(@NonNull Point2D viewCoordinates, @NonNull MapImage image)

      Creates an instance of an overlay at given view coordinates, represented by specified image.

      Parameters:
      viewCoordinates -

      The overlay's view coordinates in pixels.

      image -

      The image to draw on the map.

    • MapImageOverlay

      public MapImageOverlay(@NonNull Point2D viewCoordinates, @NonNull MapImage image, @NonNull Anchor2D anchor)

      Creates an instance of an overlay at given view coordinates, represented by specified image, with anchor point specifying how the image is positioned relative to the overlay's view coordinates.

      The anchor is a way of specifying position offset relative to image's dimensions on the view. For example, (0, 0) places the top-left corner of the image at the overlay's view coordinates. (1, 1) would place the bottom-right corner of the image at the overlay's view coordinates. (0.5, 0.5) which is the default value would center the image at the overlay's view coordinates.

      Values outside the 0..1 range are also allowed, for example (0.5, 2) would display the image centered horizontally with its bottom edge above the overlay's view coordinates at the distance in pixels that is equal to the height of the image.

      Parameters:
      viewCoordinates -

      The overlay's view coordinates in pixels.

      image -

      The image to draw on the map.

      anchor -

      The anchor point for the overlay image which specifies the position offset relative to the overlay's view coordinates.

  • Method Details

    • getViewCoordinates

      @NonNull public Point2D getViewCoordinates()

      Gets the view point in pixels on the map viewport where the overlay is drawn.

      Returns:

      The view point in pixels on the map viewport where the map overlay is drawn.

    • setViewCoordinates

      public void setViewCoordinates(@NonNull Point2D value)

      Sets the view point in pixels on the map viewport where the overlay is drawn.

      Parameters:
      value -

      The view point in pixels on the map viewport where the map overlay is drawn.

    • getDrawOrder

      public int getDrawOrder()

      Gets draw order of this MapImageOverlay. The default value is 0.

      Returns:

      Draw order of this MapImageOverlay.

    • setDrawOrder

      public void setDrawOrder(int value)

      Sets draw order of this MapImageOverlay.

      Overlays with higher draw order value are drawn on top of overlays with lower draw order.

      In case multiple overlays have the same draw order value then the order in which they were added to the scene matters. Last added overlay is drawn on top.

      Allowed range is [0, 1023]. Values outside this range will be clamped.

      Parameters:
      value -

      Draw order of this MapImageOverlay.

    • getImage

      @NonNull public MapImage getImage()

      Gets currently used map image.

      Returns:

      Image overlayed on the map.

    • setImage

      public void setImage(@NonNull MapImage value)

      Sets the image overlayed on map.

      Parameters:
      value -

      Image overlayed on the map.

    • getAnchor

      @NonNull public Anchor2D getAnchor()

      Gets current anchor point for the overlay image.

      Returns:

      The anchor point for the overlay image which specifies the position offset relative to the overlay's view coordinates.

    • setAnchor

      public void setAnchor(@NonNull Anchor2D value)

      Sets anchor point of the overlay image which specifies the position offset relative to the overlay's view coordinates.

      For example, (0, 0) places the top-left corner of the image at the overlay's view coordinates. (1, 1) would place the bottom-right corner of the image at the overlay's view coordinates. (0.5, 0.5) which is the default value would center the image at the overlay's view coordinates.

      Values outside the 0..1 range are also allowed, for example (0.5, 2) would display the image centered horizontally with its bottom edge above the overlay's view coordinates at the distance in pixels that is equal to the height of the image.

      Parameters:
      value -

      The anchor point for the overlay image which specifies the position offset relative to the overlay's view coordinates.