我需要在显示与世界上的地方是在MKMapView白天和黑夜覆盖的帮助。
我们的想法是显示哪里是晚上一个黑色不透明的颜色,哪里是白天什么都没有。我一直试图使用MKOverlay,但没有运气。
提供最小的复制代码。
struct OurMapView: UIViewRepresentable {
func makeUIView(context: Context) -> MKMapView {
let mapView = MKMapView()
mapView.showsUserLocation = true
mapView.mapType = .standard // Set the map type to satellite
return mapView
}
func updateUIView(_ uiView: MKMapView, context: Context) {
}
}
字符串
编辑:我的目标是做类似的事情,但没有切换,只是显示哪里是白天和黑夜:https://appadvice.com/app/day-night-map/741375889
1条答案
按热度按时间bksxznpy1#
由于我主要处理SwiftUI,而MapKit只有在iOS 17之后才能在SwiftUI中完全可用,所以我将向您展示我的想法(但需要SwiftUI并且目标必须是iOS 17)。
我从CLLocationCoordinate2D中创建了一个数组来在Map上显示一个多边形。
字符串
的数据