Map Legend¶
FUIMapLegend
¶
open class FUIMapLegend: FUIResizablePopoverContainer
FUIMapLegend
extends UIViewController
to show the Map Legend.
FUIMapLegend
is presented in a UIPopoverView
on iPad and presented in a UIPresentationController
on iPhone
Available in FUIMapLegend
¶
headerTextView
: aTextView
intended to display a footnote text.passThroughViews
: an array ofUIView
that a user can interact with while popover is visible
Example Initialization and Configuration¶
In view controller's viewDidLoad
method:
let 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]
Theming¶
fdlFUIMapLegendContainer_headerTextView {
font-color: @primary3;
font-name: semiboldSystem;
font-style: footnote;
}
Notes¶
- See implementation of
FUIMapLegend
using aFUIMapToolbarLegendButton
for a complete implementation.
Last update: April 14, 2021