FUIMKMapFloorplanViewController
@MainActor
open class FUIMKMapFloorplanViewController : FUIMapFloorplanViewController<FUIMKMapFloorplanContentView, MKEditingGeometryWrapper, MKEditingTypes>, EditingGeometryProducing
A subclass of FUIMapFloorplanViewController designed to be used with MapKit framework. You can use it to display business objects(points, polylines, polygons) on the map view and view details by selecting a business object. It also supports clustering of point geometries.
Usage
The map view consists of mutiple FUIGeometryLayers. By assigning geometries onto different layers, you can show/hide all geometries on a specified layer using setLayerHidden(_:hidden:) api.
- Implement
FUIMKMapViewDataSourcemethods.
In the floorplan controller viewDidLoad() set the datasource.
self.dataSource = dataSource
func numberOfLayers(in mapView: MKMapView) -> Int { return 1 }
func mapView(_ mapView: MKMapView, layerAtIndex index: Int) -> FUIGeometryLayer { return FUIGeometryLayer("Functional Location") }
func mapView(_ mapView: MKMapView, geometriesForLayer layer: FUIGeometryLayer) -> [MKAnnotation] { return polylines }
You can also add annotations/overlays to a specified layer using FUIMKMapView’s
addAnnotation(_:geometryLayer:)andaddOverlays(_:geometryLayer:)APIs. Make sure you update you data model accordingly.Please Note: If you use MapKit’s native APIs to add annotations/overlays, the
FUIMKMapViewDelegateobject is not able to manage these objects.
- Implement
MKMapViewDelegatemethods as needed.
Developer can supply custom annotation views. FUIMarkerAnnotationView is provided by the floorplan.
mapView.delegate = delegate
open func mapView(_ mapView: MKMapView, viewFor annotation: MKAnnotation) -> MKAnnotationView? {
guard let pointAnnotation = annotation as? MKPointAnnotation else { return nil }
guard let view = FUIMarkerAnnotationView(annotation: pointAnnotation, reuseIdentifier: "cell") else { return nil }
view.glyphImage = FUIIconLibrary.map.marker.venue.withRenderingMode(.alwaysTemplate)
view.priorityIcon = FUIIconLibrary.map.marker.veryHighPriority
}
FUIMKMapViewDelegateprovides more functionalities that you can make your app more powerful.
In the floorplan controller viewDidLoad() set the delegate.
self.delegate = delegate
Determine how annotation view/overlay renderer should appear. You can customize the view/render provided with fiori default styles.
func mapView(_ mapView: MKMapView, willRender overlay: MKOverlayRenderer, for geometryIndex: Int, in layer: FUIGeometryLayer, in state: FUIMapFloorplan.State) {
guard let polylineRenderer = overlayRenderer as? MKPolylineRenderer else { return }
polylineRenderer.strokeColor = UIColor.blue
polylineRenderer.setNeedsDisplay()
}
Respond to select/deselect action
func mapView(_ mapView: MKMapView, didSelect annotation: MKAnnotation, for geometryIndex: Int, in layer: FUIGeometryLayer) {}
func mapView(_ mapView: MKMapView, didSelect clusterAnnotation: MKClusterAnnotation, for geometryIndexesInLayers: [FUIGeometryLayer: [Int]]) {}
func mapView(_ mapView: MKMapView, didSelect overlay: MKOverlay, for geometryIndex: Int, in layer: FUIGeometryLayer) {}
func mapView(_ mapView: MKMapView, didSelect overlayRenderer: MKOverlayRenderer) {}
func mapView(_ mapView: MKMapView, didDeselect annotation: MKAnnotation, for geometryIndex: Int, in layer: FUIGeometryLayer) {}
func mapView(_ mapView: MKMapView, didDeselect clusterAnnotation: MKClusterAnnotation, for geometryIndexesInLayers: [FUIGeometryLayer: [Int]]) {}
func mapView(_ mapView: MKMapView, didDeselect overlay: MKOverlay, for geometryIndex: Int, in layer: FUIGeometryLayer) {}
func mapView(_ mapView: MKMapView, didDeselect overlayRenderer: MKOverlayRenderer) {}
Theming
-
The current editing geometry in edit mode. You can access this property to inspect the editing geometry in the process of editing or save it to your data model after editing is finished. Based on the currently selected geometry (point, polyline, or polygon), this variable will return a
MKMapPoint,MKPolyline, orMKPolygonaccordingly.Declaration
Swift
@MainActor open var editingGeometry: MKShape? { get } -
The GeometryType type is
MKShape.Declaration
Swift
public typealias GeometryType = MKShape -
The map view of the floorplan controller.
Declaration
Swift
@MainActor public var mapView: FUIMKMapView { get } -
The object that acts as the data source of the controller.
Declaration
Swift
@MainActor open weak var dataSource: FUIMKMapViewDataSource? { get set } -
The object that acts as the delegate of the controller.
Declaration
Swift
@MainActor open weak var delegate: FUIMKMapViewDelegate? { get set } -
An boolean value indicates if the clustering feature is enabled.
Declaration
Swift
@MainActor open var isClusteringEnabled: Bool { get set }
-
Hide/show graphics on a specific layer.
Declaration
Swift
@MainActor open func setLayerHidden(_ layer: FUIGeometryLayer, isHidden: Bool = true)Parameters
layerThe layer on which graphics are added.
hiddenA Boolean value indicating the visibility of the object. Specify true to hide the object. Specify false to show it.
-
The editing panel of the map floorplan controller. Display after switching to edit mode.
Declaration
Swift
@MainActor public var editingPanel: FUIEditingPanel<MKShape> -
Declaration
Swift
@MainActor open override func setEditing(_ editing: Bool, animated: Bool) -
Set the state of geometries at specified indexPath.
Declaration
Swift
@MainActor public func setState(_ state: FUIMapFloorplan.State, for geometryIndexesInLayer: [FUIGeometryLayer : [Int]])Parameters
stateThe state needs to be set.
geometryIndexesInLayerThe indexPaths of geometries.