MapImage

public class MapImage
extension MapImage: NativeBase
extension MapImage: Hashable

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.

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

    Declaration

    Swift

    public init(pixelData: Data, imageFormat: ImageFormat)

    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.

  • Creates a new map image from the provided image data.

    Declaration

    Swift

    public init(imageData: Data, imageFormat: ImageFormat, width: UInt32, height: UInt32)

    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.

  • 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.init(Data, ImageFormat), MapImage.init(Data, ImageFormat, UInt32, UInt32)).}

    Please note that file paths that originate, for example from a file picker (like UIDocumentPickerViewController) can be deleted by the system while the application is still running.

    Throws

    InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public init(filePath: String, width: UInt32, height: UInt32) throws

    Parameters

    filePath

    The path to image file.

    width

    The width of image in pixels.

    height

    The height of image in pixels.

  • Creates a map image object from the supplied UIImage object. Throws an error if the supplied UIImage does not represent a regular image (for example, when it represents a mask).

    Throws

    MapImage.InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public convenience init?(from uiImage: UIImage) throws

    Parameters

    uiImage

    The image to use as source data.

  • Creates a map image object using a named image asset from the application’s main bundle or another bundle which can optionally be passed in. Currently only PNG or SVG Tiny image resources are supported.

    Throws

    MapImage.InstantiationError Indicates what went wrong when the instantiation was attempted.

    Declaration

    Swift

    public convenience init(named name: String, width: Int32, height: Int32, in bundle: Bundle? = nil) throws

    Parameters

    name

    The name of the image asset.

    width

    Width of image in pixels

    height

    Height of image in pixels

    bundle

    The bundle in which the asset resides. The main application bundle is used if not specified.