Class MapImage

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

public final class MapImage extends NativeBase

Represents a drawable resource that can be used by a MapMarker, MapMarker3D or MapImageOverlay to be shown on the map. Supported formats are listed in ImageFormat. SVG format allows custom fonts in text using font-family attribute by prior registration via AssetsManager.registerFont.

It is recommended to associate a resource with a single MapImage instance in order to enable resource sharing and reduce the amount of needed memory.

  • Constructor Details

    • MapImage

      public MapImage(@NonNull byte[] pixelData, @NonNull ImageFormat imageFormat)

      Creates a new map image from the provided image data. Currently only ImageFormat.PNG is accepted.

      Parameters:
      pixelData -

      Data to be used for the image. The bytes of a PNG image datastream are expected as defined in https://www.w3.org/TR/PNG

      imageFormat -

      The format of the image data to be used.

    • MapImage

      public MapImage(@NonNull byte[] imageData, @NonNull ImageFormat imageFormat, long width, long height)

      Creates a new map image from the provided image data.

      Parameters:
      imageData -

      Data to be used for the image. For image format ImageFormat.SVG the bytes of a UTF-8 encoded string in SVG Tiny format are expected. For the format specification see https://www.w3.org/TR/SVGTiny12

      imageFormat -

      The format of the image data to be used.

      width -

      The width of the image in pixels.

      height -

      The height of the image in pixels.

    • MapImage

      public MapImage(@NonNull String filePath, long width, long height) throws InstantiationErrorException

      Creates a new map image from the provided path to the SVG Tiny or PNG image.

      Will throw an error if either the height or width equals zero or the path is empty.

      Trying to load a file that is not compliant with SVG Tiny or PNG results in an undefined behavior. In particular, loading SVG that exceeds Tiny SVG specification may result in an image that exhibits unexpected artifacts.

      The caller must ensure that the file remains accessible for the entire duration of its usage by the SDK. If that cannot be ensured, then it is recommended to either copy the file to a location that remains accessible for the entire duration of its usage by the SDK or load and pass the file content to one of the MapImage constructors that creates instances out of image data (MapImage(byte[], ImageFormat), MapImage(byte[], ImageFormat, long, long)).}

      This constructor needs read storage permission to be granted.

      Parameters:
      filePath -

      The path to image file.

      width -

      The width of image in pixels.

      height -

      The height of image in pixels.

      Throws:
      InstantiationErrorException -

      Indicates what went wrong when the instantiation was attempted.