VMMapView

@objcMembers
open class VMMapView : UIView
extension VMMapView: MGLMapViewDelegate

VMMapView is an abstract class used to display a Venue Map Data file (VMD)

Warning

DO NOT instantiate directly, instead use one of the concrete subclasses VMVectorMapView or VMRasterMapView.

Since

1.1

Internal Properties

Initializers

  • Create a new VMMapView for a given VMD using default icons, fonts initially displaying the defualt floors and buildings

    Since

    1.4

    Declaration

    Swift

    public init(vmd: VMMSMap,
                activeIndoorFloors: [VMMSBaseFloor],
                activeOutdoorFloors: [VMMSBaseFloor],
                frame: CGRect, iconBaseURL: URL?, fontBaseURL: URL?,
                styleURL: URL?, maptilerAccessToken: String? )

    Parameters

    vmd

    the venue map data

    activeIndoorFloors

    the initial indoor floors to show

    activeOutdoorFloors

    the initial outdoor floors to show

    frame

    the frame for the map

    iconBaseURL

    icon url

    fontBaseURL

    font base url

    styleURL

    A url to a MapLibre style config

    maptilerAccessToken

    MapLibre access token (only required when using a MapLibre style)

  • initially displaying the defualt floors and buildings

    Since

    1.2

    Declaration

    Swift

    public convenience init(frame: CGRect, vmd: VMMSMap)

    Parameters

    frame

    frame for the mapview

    vmd

    a VMMSMap object that contains the venue information

  • Create a new VMMapView for a given VMD using default icons, fonts initially displaying the defualt floors and buildings

    Since

    1.4

    Declaration

    Swift

    public convenience init(frame: CGRect, vmd: VMMSMap, styleURL: URL?, maptilerAccessToken: String?)

    Parameters

    frame

    frame for the mapview

    vmd

    a VMMSMap object that contains the venue information

    styleURL

    A url to a MapLibre style config

    maptilerAccessToken

    MapLibre access token (only required when using a MapLibre style)

  • Declaration

    Swift

    public convenience init(frame: CGRect, vmd: VMMSMap, maptilerAccessToken: String?)
  • Default init for nscoder

    Since

    2.0.2

    Declaration

    Swift

    public required init?(coder: NSCoder)

Public properties

  • map

    Reference to the VMD map

    Declaration

    Swift

    public var map: VMMSMap?
  • The venue ID from the VMD file

    Declaration

    Swift

    public var venueId: String
  • Reference to internal map view

    Declaration

    Swift

    public private(set) var mapView: MGLMapView? { get }
  • Delegate for receiving callbacks.

    Declaration

    Swift

    public weak var delegate: VMMapViewDelegate?
  • Use to setup views using layout constraints instead of resizing masks

    Since

    2.1

    Declaration

    Swift

    public var useAutoLayout: Bool
  • If true, builds old style building tile urls using building_outlines_1 as the directory. Otherwises, builds the tile urls for buildings as unique to each building, based on the building’s id

    Since

    1.4

    Declaration

    Swift

    public var useLegacyBuildingTileUrl: Bool
  • Get the currently visible portion of the map

    Since

    1.2

    Declaration

    Swift

    public var visibleCoordinateBounds: VMMSCoordinateBounds? { get }

    Return Value

    The rectangular lat/lng boundaries of the visible portion of the map;

  • Style for the venue

    Declaration

    Swift

    open var style: VMVenueStyle? { get set }
  • Base url/filepath for spritesheet with icons/images

    Declaration

    Swift

    public private(set) var iconBaseURL: String { get set }
  • Base url/filepath for font SDF files

    Declaration

    Swift

    public private(set) var fontBaseURL: String { get set }
  • Base url/filepath to find tiles Note: Folder structure is expected as //

    Declaration

    Swift

    public var tileBaseURL: String { get set }
  • Base url/filepath to find tiles Note: Folder structure is expected as //

    Since

    1.2.4

    Declaration

    Swift

    public var artTileBaseURL: String { get set }
  • Base url/filepath to find vector tiles for icons & text data Note: Folder structure is expected as //

    Declaration

    Swift

    public var vectorCommonBaseURL: String { get set }
  • The currently selected map unit, if any

    Declaration

    Swift

    public var selectedUnit: VMMSMapUnit? { get set }
  • All currently displayed outdoor floors for the map

    Since

    1.2

    Declaration

    Swift

    public var activeOutdoorFloors: [VMMSBaseFloor] { get set }
  • All currently displayed indoor floors for the map

    Since

    1.2

    Declaration

    Swift

    public var activeIndoorFloors: [VMMSBaseFloor] { get set }
  • The minimum allowable zoom level for the map

    • Default: 1.0

    Declaration

    Swift

    public var minZoom: Float { get set }
  • The maximium allowable zoom level for the map

    • Default: 21.0

    Declaration

    Swift

    public var maxZoom: Float { get set }
  • <#Description#>

    Declaration

    Swift

    public var zoomLevel: Float { get }
  • Declaration

    Swift

    public var bearing: CLLocationDirection { get }
  • Declaration

    Swift

    public var tilt: Double { get }
  • Declaration

    Swift

    public var centerCoordinate: CLLocationCoordinate2D { get }
  • Shows a rectangle around map tiles and othe rdebug information. Defaults to false.

    Since

    1.3

    Declaration

    Swift

    public var showTileBoundaries: Bool { get set }
  • Enable/disable tilt

    Since

    1.3.2

    Declaration

    Swift

    public var tiltEnabled: Bool { get set }
  • Display passthrough areas for debugging purposes

    Since

    2.0.2

    Declaration

    Swift

    public var showPassthroughAreas: Bool
  • A rectangular region in this view that should NOT capture touch events. They will instead be passed through to the next view in the view hierarchy.

    Since

    2.0.2

    Declaration

    Swift

    public var passthroughAreas: [CGRect] { get set }

Public Methods

  • Adjusts map’s camera to zoom and adjust position to the current floor is completely visible

    Since

    1.2

    Declaration

    Swift

    public func fixCameraToFloor(_ floor: VMMSBaseFloor?, constrainedToSize: CGSize, zoomOffset: Double, skipRotation: Bool = false)

    Parameters

    floor

    the floor to zoom to

    constrainedToSize

    the size of the screen that you want the floor visible in

    zoomOffset

    additional zoom padding, if needed

    skipRotation

    if true, resets the rotation of the map back to the initial rotation defined in the VMD

  • Add the mapview above the given view Note, when using a VMMapView in addition to another map provider (google maps, apple maps, etc), it’s recommended to attach directly above that view for the other map provider

    Declaration

    Swift

    public func attachInView(_ parent: UIView, aboveView: UIView?)

    Parameters

    parent

    the parent view to add this map to

    aboveView

    a reference view to insert above (nil to just addSubview at the top)

  • Add the mapview above the given view

    Since

    1.2

    Declaration

    Swift

    public func attachInView(_ parent: UIView, _ aboveView: UIView?)

    Parameters

    parent

    the parent view to add this map to

    aboveView

    a reference view to insert above (nil to just add at the top of the view hierarchy)

  • Adds map to parent view

    Since

    1.2

    Declaration

    Swift

    public func addToView(_ parent: UIView)

    Parameters

    parent

    the superview

  • Clears map tile cache to free up memory

    Declaration

    Swift

    public func clearTileCache()
  • Set initial map position after it’s done loading

    Since

    1.2

    Declaration

    Swift

    public func setMapPosition(target: CLLocationCoordinate2D, bearing: Float, zoomLevel: Float, pitch: Double)

    Parameters

    target

    location for the map

    bearing

    bearing for the map

    zoomLevel

    zoom for the map

    pitch

    the pitch for the map

  • Set initial map position after it’s done loading

    Since

    1.2.1

    Declaration

    Swift

    public func setMapPosition(target: CLLocationCoordinate2D, bearing: Float, zoomLevel: Float)

    Parameters

    target

    location for the map

    bearing

    bearing for the map

    zoomLevel

    zoom for the map

  • Locate the closest mapUnit to a target from a list

    @param location the target location @param list a list of units (hopefully nearby) @return the closest unit by distances

    Declaration

    Swift

    open func findClosestMapUnitInList( _ location: CLLocationCoordinate2D,
                                                     inList list: [VMMSMapUnit] ) -> VMMSMapUnit?
  • Since

    1.4

    Declaration

    Swift

    open func getMapUnitContaining(_ location: CLLocationCoordinate2D, _ floor: VMMSBaseFloor?) -> VMMSMapUnit?
  • Respond to a tap at the given location

    Declaration

    Swift

    open func handleSingleTapAt(_ location: CLLocationCoordinate2D)

    Parameters

    location

    the location of the tap

  • Selects a unit on the current floor. The unit must already be visible before setting it.

    Since

    2.0

    Declaration

    Swift

    public func selectUnit(_ unit: VMMSMapUnit)

    Parameters

    unit

    the unit on current floor.

  • Change the background layer’s alpha

    Declaration

    Swift

    public func setBackgroundAlpha(_ alpha: Float)

    Parameters

    alpha

    The new alpha value (1.0 represents fully opaque, and 0.0 represents full transparent)

  • Add annotation to the map

    Declaration

    Swift

    public func addAnnotation(_ annotation: VMMapAnnotation)

    Parameters

    annotation

    the annotation

  • Remove annotation from the map

    Declaration

    Swift

    public func removeAnnotation(_ annotation: VMMapAnnotation)

    Parameters

    annotation

    the annotation

  • Initialize an icon to be used in future map styles

    Since

    1.4

    Declaration

    Swift

    public func setImage(_ image: UIImage, forKey key: String)

    Parameters

    image

    the image

    key

    the image key

  • Initialize an icon to be used in future map styles

    Declaration

    Swift

    public func setImages(_ images: [String : UIImage])

    Parameters

    images

    key value pair of images

  • Apply a custom style to an indivudual map element

    Since

    1.2

    Declaration

    Swift

    public func setStyle(_ style: VMVenueLayerStyle, forUnit unit: VMMSMapUnit)

    Parameters

    unit

    the unit to apply the style to

    style

    the style information

  • Remove a custom style from an indivudual map element

    Since

    1.2

    Declaration

    Swift

    public func removeStyleForUnit(_ unit: VMMSMapUnit)

    Parameters

    unit

    the unit to remove the style from

Method Overrides

  • Declaration

    Swift

    open override func point(inside point: CGPoint, with event: UIEvent?) -> Bool

MGLMapViewDelegate

  • Called when map changes

    Declaration

    Swift

    open func mapViewRegionIsChanging(_ mapView: MGLMapView)

    Parameters

    mapView

    the map

  • Called to check if the map’s camera should change

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, shouldChangeFrom oldCamera: MGLMapCamera, to newCamera: MGLMapCamera) -> Bool

    Parameters

    mapView

    the map

    oldCamera

    the previous camera position

    newCamera

    the new camera position

    Return Value

    true if it is OK to change to the new camera position

  • Called if map fails to load

    Declaration

    Swift

    open func mapViewDidFailLoadingMap(_ mapView: MGLMapView, withError error: Error)

    Parameters

    mapView

    the mapview

    error

    the error

  • Called when mapview finishes loading style

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, didFinishLoading style: MGLStyle)

    Parameters

    mapView

    the mapview

    style

    the style

  • Called when map finishes loading, this is where all the setup occurs

    Declaration

    Swift

    open func mapViewDidFinishLoadingMap(_ mapView: MGLMapView)

    Parameters

    mapView

    the mapview

  • Indicates the map finished redrawing the frame

    Declaration

    Swift

    open func mapViewDidFinishRenderingFrame(_ mapView: MGLMapView, fullyRendered: Bool)

    Parameters

    mapView

    the mapview

    fullyRendered

    true if frame is full rendered

  • Indicates map is about to be redrawn

    Declaration

    Swift

    open func mapViewWillStartRenderingFrame(_ mapView: MGLMapView)

    Parameters

    mapView

    the mapview

  • Called when annotation view is selected

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, didSelect annotationView: MGLAnnotationView)

    Parameters

    mapView

    the map

    annotationView

    the selected annotation

  • Called when annotation view is deselected

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, didDeselect annotationView: MGLAnnotationView)

    Parameters

    mapView

    the map

    annotationView

    the deselected annotation

  • Called when annotation is selected

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, didSelect annotation: MGLAnnotation)

    Parameters

    mapView

    the map

    annotation

    the annotation

  • Provide stroke color for lines

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, strokeColorForShapeAnnotation annotation: MGLShape) -> UIColor

    Parameters

    mapView

    the mapview

    annotation

    the shape annotation

    Return Value

    the color

  • Provide stroke width for lines

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, lineWidthForPolylineAnnotation annotation: MGLPolyline) -> CGFloat

    Parameters

    mapView

    the mapview

    annotation

    the line

    Return Value

    the width

  • Provide alpha for shape annotation

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, alphaForShapeAnnotation annotation: MGLShape) -> CGFloat

    Parameters

    mapView

    the map

    annotation

    the shape

    Return Value

    the alpha value

  • Provide a callout view for an annotation

    Since

    1.4

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, calloutViewFor annotation: MGLAnnotation) -> MGLCalloutView?

    Parameters

    mapView

    the mapview

    annotation

    the selected annotation

    Return Value

    a callout view, or nil

  • Determine if callout should be shown

    Since

    1.4

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, annotationCanShowCallout annotation: MGLAnnotation) -> Bool

    Parameters

    mapView

    the mapview

    annotation

    the selected annotation

    Return Value

    true if callout should show

  • Provide a custom view for an annotation

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, viewFor annotation: MGLAnnotation) -> MGLAnnotationView?

    Parameters

    mapView

    the mapview

    annotation

    the annotation

    Return Value

    the custom view

  • Provide a custom image for an annoation

    Declaration

    Swift

    open func mapView(_ mapView: MGLMapView, imageFor annotation: MGLAnnotation) -> MGLAnnotationImage?

    Parameters

    mapView

    the map

    annotation

    the annotation

    Return Value

    the custom image