MPIMapView

public class MPIMapView : WKWebView
extension MPIMapView: WKNavigationDelegate

This class contains methods that help to display and interact with a Mappedin venue

  • MPIData of the venue

    Declaration

    Swift

    public var venueData: MPIData?
  • MPIMap of the current map

    Declaration

    Swift

    public var currentMap: MPIMap?
  • Map view delegate

    Declaration

    Swift

    public weak var delegate: MPIMapViewDelegate?
  • Blue dot manager

    Declaration

    Swift

    public private(set) lazy var blueDotManager: MPIBlueDotManager { get set }
  • Camera controls manager

    Declaration

    Swift

    public private(set) lazy var cameraControlsManager: MPICameraControlsManager { get set }
  • Journey manager

    Declaration

    Swift

    public private(set) lazy var journeyManager: MPIJourneyManager { get set }
  • Initialization set up for MPIMapView

    Declaration

    Swift

    public init(frame: CGRect)
  • Loads the map based on the options passed in MPIMapView

    Note

    API calls will be made to retrieve the data

    Declaration

    Swift

    public func loadVenue(options: MPIOptions.Init, showVenueOptions: MPIOptions.ShowVenue? = nil)

    Parameters

    options

    The options MPIOptions.Init to load the MPIMapView with

    Return Value

    Void

  • Shows the venue based on the venue data and options passed in MPIMapView

    Note

    An alternative method to using loadVenue where no API calls will be made; instead, data must be passed in to showVenue which takes in a data string

    Declaration

    Swift

    public func showVenue(
        venueResponse: String,
        showVenueOptions: MPIOptions.ShowVenue? = nil,
        errorCallback: ((MPIError?) -> Void)? = nil
    )

    Parameters

    venueResponse

    The full response string received from the API

    showVenueOptions

    The options MPIOptions.ShowVenue to load the MPIMapView with

    errorCallback

    Callback when the showVenue fails, contains an MPIError as the parameter, defaults to null

    Return Value

    Void

  • Shows the venue based on the venue data and options passed in MPIMapView

    Note

    An alternative method to using loadVenue where no API calls will be made; instead, data must be passed in to showVenue which takes in a deserialized MPIVenueResponse

    Declaration

    Swift

    public func showVenue(
        venueResponse: MPIVenueResponse,
        showVenueOptions: MPIOptions.ShowVenue? = nil,
        errorCallback: ((MPIError?) -> Void)? = nil
    )

    Parameters

    venueResponse

    The response from the API deserialized as MPIVenueResponse

    showVenueOptions

    The options MPIOptions.ShowVenue to load the MPIMapView with

    Return Value

    Void

  • Sets the map of the mapview to the MPIMap passed in

    Declaration

    Swift

    public func setMap(map: MPIMap, completionCallback: ((String?) -> Void)? = nil)

    Parameters

    map

    The MPIMap to set the MPIMapViewto

    completionCallback

    Callback when the MPIMapView has completed setting the map, contains an error string as the first parameter if it fails, defaults to null

    Return Value

    Void

  • Sets the map of the mapview to the MPIMap passed in

    Declaration

    Swift

    public func setMap(mapId: String, completionCallback: ((String?) -> Void)? = nil)

    Parameters

    mapId

    The id of MPIMap to set the MPIMapViewto

    completionCallback

    Callback when the MPIMapView has completed setting the map, contains an error string as the first parameter if it fails

    Return Value

    Void

  • Sets the color of the MPIPolygon

    Declaration

    Swift

    public func setPolygonColor(polygon: MPIPolygon, color: String, textColor: String? = nil, opacity: Double = 1.0)

    Parameters

    polygon

    The MPIPolygon to change the color

    color

    The color to set the MPIPolygon to, e.g ‘black’, ‘#CDCDCD’

    textColor

    The color to set the textColor of the legacyLabels, e.g ‘black’, ‘#CDCDCD’

    opacity

    The opacity of the MPIPolygon, e.g 0 to 1.0

    Return Value

    Void

  • Sets the color of the MPIPolygon

    Declaration

    Swift

    public func setPolygonColor(polygonId: String, color: String, textColor: String? = nil, opacity: Double = 1.0)

    Parameters

    polygonId

    The id of the MPIPolygon to change the color

    color

    The color to set the MPIPolygon to, e.g ‘black’, ‘#CDCDCD’

    textColor

    The color to set the textColor of the legacyLabels, e.g ‘black’, ‘#CDCDCD’

    opacity

    The opacity of the MPIPolygon, e.g 0 to 1.0

    Return Value

    Void

  • Clears color on all polygons

    Declaration

    Swift

    public func clearAllPolygonColors(completionCallback: ((String?) -> Void)? = nil)

    Parameters

    completionCallback

    Callback for when the mapview is finished clearing all polygon colors, contains an error string as the first parameter if it failed, defaults to null

    Return Value

    Void

  • Enables the blue dot so it will appear if the location is in the venue

    Declaration

    Swift

    @available(*, deprecated, message: "Use MPIMapView.blueDotManager.enable instead")
    public func enableBlueDot(options: MPIOptions.BlueDot? = nil)

    Parameters

    options

    BlueDot options, passing allowImplicitFloorLevel as true displays the blue dot on all floors, defaults to false

    Return Value

    Void

  • Disables the blue dot so it does not appear on the mapview

    Declaration

    Swift

    @available(*, deprecated, message: "Use MPIMapView.blueDotManager.disable instead")
    public func disableBlueDot()

    Return Value

    Void

  • Updates the position of the blue dot on the mapview

    Declaration

    Swift

    @available(*, deprecated, message: "Use MPIMapView.blueDotManager.updatePosition instead")
    public func updatePosition(position: MPIPosition)

    Parameters

    position

    The MPIPosition of the blue dot

    Return Value

    Void

  • Declaration

    Swift

    public func getDirections(
        to: MPINavigatable,
        from: MPINavigatable,
        accessible: Bool = true,
        directionsCallback: @escaping (MPIDirections?) -> Void
    )

    Parameters

    to

    The destination MPINavigatable for the directions

    from

    The starting MPINavigatable for the directions

    accessible

    Whether or not the directions are accessible (uses connections that are accessible)

    directionsCallback

    The callback that contains the MPIDirections

    Return Value

    Void

  • Declaration

    Swift

    public func getDirections(
        to: MPIDestinationSet,
        from: MPINavigatable,
        accessible: Bool = true,
        directionsCallback: @escaping ([MPIDirections]?) -> Void
    )

    Parameters

    to

    The multi destination list of MPINavigatables for the directions

    from

    The starting MPINavigatable for the directions

    accessible

    Whether or not the directions are accessible (uses connections that are accessible)

    directionsCallback

    The callback that contains the MPIDirections

    Return Value

    Void

  • Draws a path on the MPIMapView

    Declaration

    Swift

    public func drawPath(path: [MPINode], pathOptions: MPIOptions.Path? = nil)

    Parameters

    path

    A list of MPINode that the path will be drawn from

    pathOptions

    Path options to customize how the path is drawn, defaults to null

    Return Value

    Void

  • Remove all paths on the MPIMapView

    Declaration

    Swift

    public func removeAllPaths(completionCallback: ((String?) -> Void)? = nil)

    Parameters

    completionCallback

    Callback when the MPIMapView has completed removing all the paths, contains an error string as the first parameter if it fails, defaults to nil

    Return Value

    Void

  • Draws a journey on the MPIMapView

    Declaration

    Swift

    @available(*, deprecated, message: "Use MPIMapView.journeyManager.draw instead")
    public func drawJourney(directions: MPIDirections, options: MPIOptions.Journey? = nil)

    Parameters

    directions

    The directions for the journey

    options

    journey options, include setting a connectionTemplateString and pathOptions

    Return Value

    Void

  • Remove all paths and connection tooltips on the MPIMapView

    Declaration

    Swift

    @available(*, deprecated, message: "Use MPIMapView.journeyManager.clear instead")
    public func clearJourney()

    Return Value

    Void

  • Create a marker for a MPINode

    Declaration

    Swift

    public func createMarker(node: MPINode, contentHtml: String, markerOptions: MPIOptions.Marker = MPIOptions.Marker()) -> String

    Parameters

    node

    The MPINode to set the marker on

    contentHtml

    An HTML string used to display the marker

    markerOptions

    Marker options, including a marker rank, and an anchor

    Return Value

    Void

  • Create a marker for a MPICoordinate

    Declaration

    Swift

    public func createMarker(coordinate: MPIMap.MPICoordinate, contentHtml: String, markerOptions: MPIOptions.Marker = MPIOptions.Marker()) -> String

    Parameters

    coordinate

    The MPICoordinate to set the marker on

    contentHtml

    An HTML string used to display the marker

    markerOptions

    Marker options, including a marker rank, and an anchor

    Return Value

    Void

  • Remove the marker of the MPINode

    Note

    cannot remove a marker id that does not exist yet

    Declaration

    Swift

    public func removeMarker(id: String)

    Parameters

    id

    The id of the marker to remove

    Return Value

    Void

  • Focus on a list of nodes and/or polygons provided in the focus options

    Declaration

    Swift

    public func focusOn(focusOptions: MPIOptions.Focus)

    Parameters

    focusOptions

    MPIOptions.Focus Provides the options for what to focus on

    Return Value

    Void

  • Adds an interactive polygon (allows it to be clickable) Note: usually, polygons with locations attached to them are set to be interactive by default. However, certain polygons might not be. Use this public function if you want to set certain polygons to be interactive.

    Declaration

    Swift

    public func addInteractivePolygon(polygon: MPIPolygon)

    Parameters

    polygon

    The MPIPolygon to make interactive

    Return Value

    Void

  • Adds an interactive polygon (allows it to be clickable)

    Declaration

    Swift

    public func addInteractivePolygon(polygonId: String)

    Parameters

    polygonId

    The id of the polygon to make interactive

    Return Value

    Void

  • Label all polygons with locations either loaded via the API or passed in

    Declaration

    Swift

    public func labelAllLocations(options: MPIOptions.FloatingLabelAllLocations? = nil)

    Parameters

    options

    Customization options for the affected smart labels

  • Label all polygons with locations either loaded via the API or passed in

    Declaration

    Swift

    public func labelAllLocations(options: MPIOptions.FlatLabelAllLocations? = nil)

    Parameters

    options

    Customization options for the affected flat labels

  • Removes all labels

    Declaration

    Swift

    public func removeAllLabels()

    Return Value

    Void

  • Sets a label for the MPIPolygon

    Declaration

    Swift

    public func labelPolygon(polygon: MPIPolygon, options: MPIOptions.FloatingLabel)

    Parameters

    polygon

    The MPIPolygon to set the label

    options

    Provides the options MPIOptions.Label to customize how the label is

    Return Value

    Void

  • Sets a label for the MPIPolygon

    Declaration

    Swift

    public func labelPolygon(polygonId: String, options: MPIOptions.FloatingLabel)

    Parameters

    polygonId

    The id of the MPIPolygon to set the label

    options

    Provides the options MPIOptions.Label to customize how the label is

    Return Value

    Void

  • Sets a label for the MPIPolygon

    Declaration

    Swift

    public func labelPolygon(polygon: MPIPolygon, options: MPIOptions.FlatLabel)

    Parameters

    polygon

    The MPIPolygon to set the flat label

    options

    Provides the options MPIOptions.LegacyLabel to customize how the flat label is

    Return Value

    Void

  • Sets a label for the MPIPolygon

    Declaration

    Swift

    public func labelPolygon(polygonId: String, options: MPIOptions.FlatLabel)

    Parameters

    polygonId

    The id of the MPIPolygon to set the flat label

    options

    Provides the options MPIOptions.FlatLabel to customize how the flat label is

    Return Value

    Void

  • Gets the nearest node by screen coordinates

    Declaration

    Swift

    public func getNearestNodeByScreenCoordinates(x: Int, y: Int, map: MPIMap? = nil, nearestNodeCallback: @escaping (MPINode?) -> Void)

    Parameters

    x

    The x coordinate based off WebView dimensions

    y

    The y coordinate based off WebView dimensions

    map

    Optional map to find the nearest node on, defaults to the current map if null

    nearestNodeCallback

    Returns a node if it finds one

    Return Value

    Void

  • Called when web view has started to receive content for the main frame

    Declaration

    Swift

    public func webView(_ webView: WKWebView, didCommit navigation: WKNavigation!)
  • Called when page has finished loading

    Declaration

    Swift

    public func webView(_ webView: WKWebView, didFinish navigation: WKNavigation!)
  • Called if page has failed to load

    Declaration

    Swift

    public func webView(_ webView: WKWebView, didFail navigation: WKNavigation!, withError error: Error)