FUIMapToolbar
open class FUIMapToolbar : UIView, FUIBackgroundSchemeSupporting
A View that wraps the FUIMapToolbarButton
in a vertical stack.
- The
FUIMapToolbar
holds a maximum of 6FUIMapToolbarButton
. - Default variants of
FUIMapToolbarButton
exist within the SDK. See,FUIMapToolbarSettingsButton
,FUIMapToolbarUserLocationButton
,FUIMapToolbarZoomExtentButton
, orFUIMapToolbarLegendButton
- The
FUIMapToolbar
can be presented in either a dark or light variant. - The
FUIMapToolbar
will be pinned to the givenMKMapView
in the top right corner
Usage
var toolbar = FUIMapToolbar(mapView: mapView)
toolbar.backgroundColorScheme = .dark // defaults to `.light`
let locationButton = FUIMapToolbarUserLocationButton(mapView: self.mapView)
let zoomExtentsButton = FUIMapToolbarZoomExtentButton(mapView: self.mapView)
toolbar.items = [locationButton, zoomExtentsButton]
-
A list of
FUIMapToolbarButton
used to populate theFUIMapToolbar
. ThecolorScheme
of theFUIMapToolbarButton
s is determined by theFUIMapToolbar
colorScheme
.FUIMapToolbarButton
have a preset priority and are sorted in the following way- Settings
- User Location
- Clear All
- Legend
- Zoom Extent
- Custom Button
Declaration
Swift
public var items: [FUIMapToolbarButton] { get set }
-
Color scheme for the toolbar background color:
.dark
means that the background color will be dark. Is propagatated to child toolbar items. The defaultBackgroundColorScheme
islightBackground
Declaration
Swift
public var backgroundColorScheme: FUIBackgroundColorScheme { get set }
-
An initializer to create a
FUIMapToolbar
. It takes in apinnedView
to constrain the toolbar to the top right section of the view.Declaration
Swift
public init(mapView pinnedView: UIView)
Parameters
pinnedView
A
MKMapView
reference, which will be used for pinning constraints for the toolbar.
-
FUIMapToolbar.ClearAllButton
inherits from the FUIButton class and is presented within theFUIMapToolbar
. This moves the floorplan panels (detail panel & legend) out of view to see more of the map.Available in
FUIMapToolbar.ClearAllButton
:mapFloorplan
: theFUIMKMapFloorplanViewController
the button interacts with to show and hide panels.
Usage:
See morelet toolbar = FUIMapToolbar(mapView: mapView) let clearAllButton = FUIMapToolbar.ClearAllButton(mapFloorplan: self) toolbar.items = [clearAllButton]
Declaration
Swift
open class ClearAllButton : FUIMapToolbarButton
-
FUIMapToolbarLegendButton
is a subclass ofFUIMapToolbarButton
. This button is intended to show theFUIMapLegend
on tap. It is up to the developer to manage switching between presented views:Usage
See morelet toolbar = FUIMapToolbar(mapView: mapView) let legend = FUIMapLegend() legend.toolbarButton = FUIMapToolbarLegendButton() legend.headerTextView.text = "MapView Example Legend" legend.passThroughViews = [toolbar, mapView] var venueItem = FUIMapLegendItem(title: "Self Service") venueItem.backgroundColor = UIColor.preferredFioriColor(forStyle: .map1) let venueImage = FUIAttributedImage(image: FUIIconLibrary.map.marker.venue.withRenderingMode(.alwaysTemplate)) venueImage.tintColor = .white venueItem.icon = FUIMapLegendIcon(glyphImage: venueImage) var valetItem = FUIMapLegendItem(title: "Valet") valetItem.backgroundColor = UIColor.preferredFioriColor(forStyle: .map2) let valetImage = FUIAttributedImage(image: FUIIconLibrary.map.marker.walk.withRenderingMode(.alwaysTemplate)) valetImage.tintColor = .white valetItem.icon = FUIMapLegendIcon(glyphImage: valetImage) valetItem.line = FUIMapLegendLine(dashPattern: [10,8], dashPhase: 3.0) let highActivityRegion = FUIMapLegendFillItem() highActivityRegion.fillColor = UIColor.preferredFioriColor(forStyle: .map3) highActivityRegion.borderColor = UIColor.preferredFioriColor(forStyle: .map3) var highActivityRegionItem = FUIMapLegendItem(title: "High Activity Region") highActivityRegionItem.fillItem = highActivityRegion var highTrafficPathItem = FUIMapLegendItem(title: "High Traffic Path") highTrafficPathItem.backgroundColor = UIColor.preferredFioriColor(forStyle: .map4) highTrafficPathItem.line = FUIMapLegendLine(dashPattern: [2,2], dashPhase: 0.0) legend.items = [highActivityRegionItem, valetItem, venueItem, highTrafficPathItem] let legendHandler: ((FUIButton) -> Void)? = { [weak self] button in DispatchQueue.main.async { var dismissLegendAndRestoreCachedController = { [unowned self, unowned button] in self.dismiss(animated: true, completion: { button.isSelected = false }) } let presentNewLegendPhone = { self.present(legend, animated: true, completion: nil) } let presentNewLegendPad = { legend.setupPopoverAttributes(popOver: legend.popoverPresentationController!, sender: button) if self.presentedViewController == nil { self.present(legend, animated: false, completion: nil) } } guard button.isSelected else { dismissLegendAndRestoreCachedController() return } let presentNewClosure = UIDevice.current.userInterfaceIdiom == .phone ? presentNewLegendPhone : presentNewLegendPad guard let presentedController = UIDevice.current.userInterfaceIdiom == .phone ? self.presentedViewController : self.popoverPresentationController?.presentedViewController else { presentNewClosure() return } if presentedController == legend { dismissLegendAndRestoreCachedController() } else { self.dismiss(animated: true, completion: { presentNewClosure() }) } } } legend.toolbarButton?.didSelectHandler = legendHandler let locationButton = FUIMapToolbarUserLocationButton(mapView: self.mapView) toolbar.items = [legend.toolbarButton!, locationButton]
Declaration
Swift
open class LegendButton : FUIMapToolbarButton
-
FUIMapToolbarSettingsButton
inherits from the FUIButton class and is presented within theFUIMapToolbar
. It is up to the developer to manage the transition between the presented views (example: legend or the panel container). A sample has been provided to show the presentation and dismissal of the view controller.Usage
let settingsButton = FUIMapToolbarSettingsButton() settingsButton.didSelectHandler = { [weak self] button in DispatchQueue.main.async { let settings = DevMapSettingsViewController() settings.dismissButton = button let navController = UINavigationController(rootViewController: settings) if !(UIDevice.current.userInterfaceIdiom == .phone) { settings.modalPresentationStyle = .formSheet navController.modalPresentationStyle = .formSheet self.present(navController, animated: true, completion: nil) } else { navController.modalPresentationStyle = .overFullScreen let dismissClosure: (() -> Void)? = { [weak self] in self.dismiss(animated: true, completion: nil) } settings.dismissClosure = dismissClosure self.present(navController, animated: true, completion: nil) } } } var toolbar = FUIMapToolbar(mapView: mapView) let data = [settingsButton] toolbar.items = data
Supplementary Classes
See moreclass DevMapSettingsViewController: UITableViewController { var dismissButton: FUIButton? var dataSource: [String] = { let mapViewOptions = "Map View Options" let featureLayersOptions = "Feature Layers Options" let nearMeRadius = "Near Me Radius" let mapUnitOfMeasure = "Map Unit of Measure" return [mapViewOptions, featureLayersOptions, nearMeRadius, mapUnitOfMeasure] }() var dismissClosure: (() -> Void)? = nil var completionButton: FUIButton? = nil var completionClosure: ((FUIButton) -> Void)? = nil override func viewDidLoad() { navigationItem.leftBarButtonItem = UIBarButtonItem(title: "Close", style: .plain, target: self, action: #selector(dismissVC)) self.navigationController?.title = "Map Settings" tableView.dataSource = self tableView.delegate = self } override func numberOfSections(in tableView: UITableView) -> Int { return dataSource.count } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { let settingsCell = UITableViewCell() settingsCell.textLabel?.text = dataSource[indexPath.section] if dataSource[indexPath.section] == "Near Me Radius" { let switchView = UISwitch() settingsCell.accessoryView = switchView } else { settingsCell.accessoryType = UITableViewCellAccessoryType.disclosureIndicator } return settingsCell } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { return 1 } @objc func dismissVC() { DispatchQueue.main.async { self.dismissButton?.isSelected = false } guard (UIDevice.current.userInterfaceIdiom == .phone) else { self.dismiss(animated: true , completion: { guard let completionClosure = self.completionClosure, let completionButton = self.completionButton else { return } completionClosure(completionButton) }) return } guard let closure = self.dismissClosure else { return } closure() } }
Declaration
Swift
open class SettingsButton : FUIMapToolbarButton
-
FUIMapToolbarUserLocationButton
is a subclass ofFUIMapToolbarButton
. This button centers on the user’s location for a given map with regionExample Initialization and Configuration:
See morelet toolbar = FUIMapToolbar(mapView: mapView) let locationButton = FUIMapToolbarUserLocationButton(mapView: self.mapView) toolbar.items = [locationButton]
Declaration
Swift
open class UserLocationButton : FUIMapToolbarButton, UIGestureRecognizerDelegate
-
FUIMapToolbar.ZoomExtentButton
inherits from the FUIButton class and is presented within theFUIMapToolbar
. This button zooms accordingly to show all annotations in the mapView.Available in
FUIMapToolbar.ZoomExtentButton
:mapView
: aMKMapView
to zoom and show all annotations
Usage:
See morelet point1 = MKPointAnnotation() point1.coordinate = CLLocationCoordinate2D(latitude: 37.3318, longitude: -122.0312) let point2 = MKPointAnnotation() point2.coordinate = CLLocationCoordinate2D(latitude: 37.3988313, longitude: -122.1487375) let annotations = [point1, point2] mapView.addAnnotations(annotations) let toolbar = FUIMapToolbar(mapView: mapView) let locationButton = FUIMapToolbar.ZoomExtentButton(mapView: self.mapView) toolbar.items = [locationButton]
Declaration
Swift
open class ZoomExtentButton : FUIMapToolbarButton