Map-Expert Skill
This skill provides expert patterns for working with the complex mapping features in the Kashat application.
Core Concepts
1. MapKit 2023+ (SwiftUI)
Always use the modern Map and Annotation APIs. Avoid MapMarker or legacy MKMapView wrappers unless strictly necessary for backward compatibility.
2. Environment Object Provisioning
CRITICAL: Annotations in SwiftUI's Map closure often lose their environment object inheritance. Always explicitly pass required objects to subviews inside annotations.
swift
Annotation(spot.name, coordinate: spot.coordinate) {
SpotMarkerView(spot: spot)
.environmentObject(store) // ESSENTIAL
}
3. Feature Integrations
Convoy Tracking
- •Use
ConvoyManagerto fetch active members. - •Display members using
Annotationwith a distinctcar.fillicon. - •Ensure the "القافلة" filter chip is respected in the
filteredSpotslogic or map display.
Weather Overlays
- •Integrate with
WeatherManager.shared.getWeather. - •Use
WeatherCapsulefor center-coordinate weather data. - •Listen for
SevereWeatherAlertnotifications to trigger the floating alert banner.
Best Practices
- •Performance: Batch map updates and avoid excessive re-renders by optimizing the
filteredSpotscomputed property. - •Visuals: Use
.ultraThinMaterialfor overlays to maintain a premium "Glass" aesthetic. - •RTL Support: Ensure labels and icons are mirrored correctly for Arabic users where appropriate.