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.pngis accepted.Declaration
Swift
public init(pixelData: Data, imageFormat: ImageFormat)Parameters
pixelDataData to be used for the image. The bytes of a PNG image datastream are expected as defined in https://www.w3.org/TR/PNG
imageFormatThe 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
imageDataData to be used for the image. For image format
ImageFormat.svgthe bytes of a UTF-8 encoded string in SVG Tiny format are expected. For the format specification see https://www.w3.org/TR/SVGTiny12imageFormatThe format of the image data to be used.
widthThe width of the image in pixels.
heightThe 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
MapImageconstructors 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
InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public init(filePath: String, width: UInt32, height: UInt32) throwsParameters
filePathThe path to image file.
widthThe width of image in pixels.
heightThe height of image in pixels.
-
Creates a map image object from the supplied
UIImageobject. Throws an error if the suppliedUIImagedoes not represent a regular image (for example, when it represents a mask).Throws
MapImage.InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public convenience init?(from uiImage: UIImage) throwsParameters
uiImageThe 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.InstantiationErrorIndicates what went wrong when the instantiation was attempted.Declaration
Swift
public convenience init(named name: String, width: Int32, height: Int32, in bundle: Bundle? = nil) throwsParameters
nameThe name of the image asset.
widthWidth of image in pixels
heightHeight of image in pixels
bundleThe bundle in which the asset resides. The main application bundle is used if not specified.