MapImageOverlay (API Reference)
Class MapImageOverlay
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 Summary
ConstructorsConstructorDescriptionMapImageOverlay(Point2D viewCoordinates, MapImage image) Creates an instance of an overlay at given view coordinates, represented by specified image.MapImageOverlay(Point2D viewCoordinates, MapImage image, 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. -
Method Summary
Modifier and TypeMethodDescriptionGets current anchor point for the overlay image.intGets draw order of thisMapImageOverlay.getImage()Gets currently used map image.Gets the view point in pixels on the map viewport where the overlay is drawn.voidSets anchor point of the overlay image which specifies the position offset relative to the overlay's view coordinates.voidsetDrawOrder(int value) Sets draw order of thisMapImageOverlay.voidSets the image overlayed on map.voidsetViewCoordinates(Point2D value) Sets the view point in pixels on the map viewport where the overlay is drawn.
-
Constructor Details
-
MapImageOverlay
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
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
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
Gets currently used map image.
- Returns:
Image overlayed on the map.
-
setImage
Sets the image overlayed on map.
- Parameters:
value-Image overlayed on the map.
-
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
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.
-