PolylineState
PolylineState
Section titled “PolylineState”PolylineState is an ObservableObject used by Polyline(state:).
Use it when a route, track, or line style needs to update without recreating the overlay declaration.
Public Properties
Section titled “Public Properties”id: StringstrokeColor: UIColorstrokeWidth: Doublegeodesic: Boolpoints: [GeoPointProtocol]extra: Any?onClick: OnPolylineEventHandler?
let polylineState = PolylineState( points: [ GeoPoint(latitude: 35.6812, longitude: 139.7671), GeoPoint(latitude: 35.6586, longitude: 139.7454) ], strokeColor: .blue, strokeWidth: 4)
Polyline(state: polylineState)
polylineState.points.append(GeoPoint(latitude: 35.7101, longitude: 139.8107))polylineState.strokeColor = .redRoute Updates
Section titled “Route Updates”Replace the full points array when a route is recalculated:
polylineState.points = recalculatedRoutepolylineState.strokeWidth = 5Use onClick when the user should be able to select a route or inspect line metadata stored in extra.