MapViewBase

public protocol MapViewBase : AnyObject

Represents the available public API from MapView.

  • Callback for a pick request. In case of an error the result is not set.

    Declaration

    Swift

    typealias PickMapHandler = (_ mapPickResult: MapPickResult?) -> Void

    Parameters

    mapPickResult

    The operation result.

  • Indicates whether this instance is valid.

    Declaration

    Swift

    var isValid: Bool { get }
  • The camera to control the view for the map.

    Declaration

    Swift

    var camera: MapCamera { get }
  • The gestures control object for setting up the capture of gestures.

    Declaration

    Swift

    var gestures: Gestures { get }
  • Map scene associated with this map view.

    Declaration

    Swift

    var mapScene: MapScene { get }
  • Map context associated with this map view.

    Declaration

    Swift

    var mapContext: MapContext { get }
  • Here Map associated with this map view.

    Declaration

    Swift

    var hereMap: HereMap { get }
  • The size of this map view in physical pixels.

    Declaration

    Swift

    var viewportSize: Size2D { get }
  • Maximum render frame rate in frames per second.

    Declaration

    Swift

    var frameRate: Int32 { get set }
  • The pixel scale factor used by this MapView.

    Pixel scale is 0.0 if the map view is not initialized.

    In cases where the MapView moves in between screens (e.g. from main screen to a CarPlay screen), / the most up-to-date pixel scale value can be obtained after a render target gets attached to the view. / To get notified when a render target gets attached to the MapView, see MapViewLifecycleDelegate.

    Declaration

    Swift

    var pixelScale: Double { get }
  • Provides the size of the watermark in physical pixels.

    Declaration

    Swift

    var watermarkSize: Size2D { get }
  • Converts view coordinates (in pixels) to geographical coordinates.

    An optional altitude component of the resulting geographical coordinate is not set.

    If the view coordinates specify a point above a horizon, then the result is geographical coordinates of the point on a horizon below the specified view coordinates.

    The fog effect is ignored for the calculation, meaning that for the view point within the area covered by the fog, the result is geographical coordinates that would be displayed at the specified point if the fog effect was not applied.

    If the render surface is not attached, it will return nil.

    Declaration

    Swift

    func viewToGeoCoordinates(viewCoordinates: Point2D) -> GeoCoordinates?

    Parameters

    viewCoordinates

    Point inside the view to convert.

    Return Value

    The geographical coordinates under specified view point or nil if there is no render surface attached.

  • Converts geographical coordinates to view coordinates (in pixels).

    If specified, altitude of the input coordinates is interpreted as altitude above sea level. If not specified, the input coordinates are interpreted as being on ground elevation. The above distinction is only relevant when 3D terrain feature is enabled.

    The resulting view coordinates might be outside of current viewport, i.e. result might contain values less than zero or greater than view’s dimensions.

    If the render surface is not attached, it will return nil.

    Declaration

    Swift

    func geoToViewCoordinates(geoCoordinates: GeoCoordinates) -> Point2D?

    Parameters

    geoCoordinates

    Geographical coordinates to convert.

    Return Value

    The view coordinates of the specified geographical point or nil if there is no render surface attached.

  • Sets the position of the HERE logo watermark within the map view.

    By default, the watermark is aligned to the bottom-right corner of the view: Anchor2D(1.0, 1.0) and Point2D(-watermarkSize.width / 2, -watermarkSize.height / 2). It is recommended to change the default position only if necessary to avoid overlapping UI elements. The watermark should always be fully visible within the view. The anchor point on the watermark is its center (width/2, height/2), around which it will be placed in the map view. For map views smaller than 250 dip in both width and height, the watermark will not be shown.

    Declaration

    Swift

    func setWatermarkLocation(anchor: Anchor2D, offset: Point2D)

    Parameters

    anchor

    Anchor point in normalized view coordinates [0, 1]. Map view’s origin at (0, 0) indicates a top-left corner of the map view. Out of boundary anchor point values will be clamped to the [0, 1] range.

    offset

    A horizontal and vertical offset (expressed in positive/negative pixel coordinates) that allows shifting the watermark from the anchor point position in one or the other direction. For the quadrant of values expressing visible part of the map view negative offset shifts the watermark to the direction of the origin, positive - away from it. For example, the offset of (-10, 5) will shift the watermark 10px to the left and 5px to the bottom. If specified offset will result in watermark being completely or partially out-of-view the offset will be adjusted internally so that watermark is fully visible. Offset is not being scaled when the map view size changes.

  • Adds a MapViewLifecycleDelegate to this map view. Adding the same object multiple times has no effect.

    Declaration

    Swift

    func addLifecycleDelegate(_ lifecycleListener: MapViewLifecycleDelegate)

    Parameters

    lifecycleListener

    An object to be notified of lifecycle events.

  • Removes a MapViewLifecycleDelegate from this map view. Trying to remove an object that was not added or was removed before has no effect.

    Declaration

    Swift

    func removeLifecycleDelegate(_ lifecycleListener: MapViewLifecycleDelegate)

    Parameters

    lifecycleListener

    An object to stop being notified of lifecycle events.

  • Returns all map content located inside the specified pick area. Content to be picked is specified by a pick content filter. The pick area is defined by a rectangle in map view coordinates in pixels, relative to the map view’s origin at (0, 0) which indicates the top-left corner of the map view.

    Declaration

    Swift

    func pick(filter: MapScene.MapPickFilter?, inside viewArea: Rectangle2D, completion: @escaping MapViewBase.PickMapHandler)

    Parameters

    filter

    Filter for the map content to be picked. When a filter is not set all of the pickable content will be picked.

    viewArea

    The rectangular pixel area of the view inside which map content will be picked. View area is relative to the map view’s origin at (0, 0) at the top-left corner of the map view.

    completion

    Callback to call with the result. This will be called on a main thread when pick operation completes.