MPIMapView
public class MPIMapView : WKWebView
extension MPIMapView: WKNavigationDelegate
This class contains methods that help to display and interact with a Mappedin venue
-
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 dataDeclaration
Swift
public func loadVenue(options: MPIOptions.Init, showVenueOptions: MPIOptions.ShowVenue? = nil)
Parameters
options
The options
MPIOptions.Init
to load theMPIMapView
withReturn 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 stringDeclaration
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 theMPIMapView
witherrorCallback
Callback when the showVenue fails, contains an
MPIError
as the parameter, defaults to nullReturn 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 deserializedMPIVenueResponse
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 theMPIMapView
withReturn Value
Void
-
Sets the map of the mapview to the
MPIMap
passed inDeclaration
Swift
public func setMap(map: MPIMap, completionCallback: ((String?) -> Void)? = nil)
Parameters
map
The
MPIMap
to set theMPIMapView
tocompletionCallback
Callback when the
MPIMapView
has completed setting the map, contains an error string as the first parameter if it fails, defaults to nullReturn Value
Void
-
Sets the map of the mapview to the
MPIMap
passed inDeclaration
Swift
public func setMap(mapId: String, completionCallback: ((String?) -> Void)? = nil)
Parameters
mapId
The id of
MPIMap
to set theMPIMapView
tocompletionCallback
Callback when the
MPIMapView
has completed setting the map, contains an error string as the first parameter if it failsReturn 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 colorcolor
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.0Return 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 colorcolor
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.0Return 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 dotReturn Value
Void
-
Get directions to an
MPINavigatable
(MPINode
,MPILocation
,MPIPolygon
,MPIVortex
) from anMPINavigatable
Declaration
Swift
public func getDirections( to: MPINavigatable, from: MPINavigatable, accessible: Bool = true, directionsCallback: @escaping (MPIDirections?) -> Void )
Parameters
to
The destination
MPINavigatable
for the directionsfrom
The starting
MPINavigatable
for the directionsaccessible
Whether or not the directions are accessible (uses connections that are accessible)
directionsCallback
The callback that contains the
MPIDirections
Return Value
Void
-
Get directions to an
MPINavigatable
(MPINode
,MPILocation
,MPIPolygon
,MPIVortex
) from anMPINavigatable
Declaration
Swift
public func getDirections( to: MPIDestinationSet, from: MPINavigatable, accessible: Bool = true, directionsCallback: @escaping ([MPIDirections]?) -> Void )
Parameters
to
The multi destination list of
MPINavigatable
s for the directionsfrom
The starting
MPINavigatable
for the directionsaccessible
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 frompathOptions
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 nilReturn 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 oncontentHtml
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 oncontentHtml
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 yetDeclaration
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 onReturn 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 interactiveReturn 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.LabelAllLocations? = 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.LegacyLabelAllLocations? = nil)
Parameters
options
Customization options for the affected legacy 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.Label)
Parameters
polygon
The
MPIPolygon
to set the labeloptions
Provides the options
MPIOptions.Label
to customize how the label isReturn Value
Void
-
Sets a label for the
MPIPolygon
Declaration
Swift
public func labelPolygon(polygonId: String, options: MPIOptions.Label)
Parameters
polygonId
The id of the
MPIPolygon
to set the labeloptions
Provides the options
MPIOptions.Label
to customize how the label isReturn Value
Void
-
Sets a label for the
MPIPolygon
Declaration
Swift
public func labelPolygon(polygon: MPIPolygon, options: MPIOptions.LegacyLabel)
Parameters
polygon
The
MPIPolygon
to set the legacy labeloptions
Provides the options
MPIOptions.LegacyLabel
to customize how the legacy label isReturn Value
Void
-
Sets a label for the
MPIPolygon
Declaration
Swift
public func labelPolygon(polygonId: String, options: MPIOptions.LegacyLabel)
Parameters
polygonId
The id of the
MPIPolygon
to set the legacy labeloptions
Provides the options
MPIOptions.LegacyLabel
to customize how the legacy label isReturn Value
Void
-
Gets the nearest node by screen coordinates
Declaration
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)