FUIMKMapFloorplanViewController
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 FUIGeometryLayer
s. By assigning geometries onto different layers, you can show/hide all geometries on a specified layer using setLayerHidden(_:hidden:) api.
- Implement
FUIEsriMapViewDataSource
methods.
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
FUIMKMapViewDelegate
object is not able to manage these objects.
- Implement
MKMapViewDelegate
methods 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
}
FUIMKMapViewDelegate
provides 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
, orMKPolygon
accordingly.Declaration
Swift
open var editingGeometry: MKShape? { get }
-
Undocumented
Declaration
Swift
public typealias GeometryType = MKShape
-
The map view of the floorplan controller.
Declaration
Swift
public var mapView: FUIMKMapView { get }
-
The object that acts as the data source of the controller.
Declaration
Swift
open weak var dataSource: FUIMKMapViewDataSource? { get set }
-
The object that acts as the delegate of the controller.
Declaration
Swift
open weak var delegate: FUIMKMapViewDelegate? { get set }
-
An boolean value indicates if the clustering feature is enabled.
Declaration
Swift
open var isClusteringEnabled: Bool { get set }
-
Hide/show graphics on a specific layer.
Declaration
Swift
open func setLayerHidden(_ layer: FUIGeometryLayer, isHidden: Bool = true)
Parameters
layer
The layer on which graphics are added.
hidden
A 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
public var editingPanel: FUIEditingPanel<MKShape>
-
Declaration
Swift
open override func setEditing(_ editing: Bool, animated: Bool)
-
Set the state of geometries at specified indexPath.
Declaration
Swift
public func setState(_ state: FUIMapFloorplan.State, for geometryIndexesInLayer: [FUIGeometryLayer : [Int]])
Parameters
state
The state needs to be set.
geometryIndexesInLayer
The indexPaths of geometries.