mapkit

MKMapView crashing if zooming while adding annotations

有些话、适合烂在心里 提交于 2020-06-26 16:43:10
问题 It looks like I'm running into an issue where I can reliably cause my MKMapView to crash if I'm adding annotations while the map's visible region is being changed. I've boiled the code that is causing it down to a pretty simple implementation, and I'm reproducing it here: NSMutableArray *pointAnnotationArray = [[NSMutableArray alloc] init]; MKCoordinateRegion coordRegion = [mapViewOutlet region]; float randMax = 0.1; for (int i = 0; i < 100; i++){ float randomDeviation1 = (((float)

iOS MapKit bug using MKCircle overlays in satelliteFlyover and hybridFlyover MapTypes

陌路散爱 提交于 2020-05-15 21:46:32
问题 I think I've found a bug in MapKit when using satelliteFlyover and hybridFlyover MapTypes to display large paths across the globe. If you display both MKPolylines and MKCircles on the same map, as you zoom in you will see large sections of the overlays disappear. I've seen the same basic bug since at least iOS 10. This sample code is for SwiftUI in iOS 13 with Xcode 11+. To duplicate this problem, just create a new SwiftUI project for iOS and copy all of this code into ContentView.swift. It

How to update UIViewRepresentable with ObservableObject

五迷三道 提交于 2020-04-12 19:47:48
问题 I'm trying to learn Combine with SwiftUI and I'm struggling how to update my view (from UIKit) with ObservableObject (previously BindableObject ). The issue is that, obviously, method updateUIView will not fire once the @Published object sends the notification it was changed. class DataSource: ObservableObject { @Published var locationCoordinates = [CLLocationCoordinate2D]() var value: Int = 0 init() { Timer.scheduledTimer(withTimeInterval: 3, repeats: true) { timer in self.value += 1 self

MKPolyline broken when using type satelliteFlyover?

只愿长相守 提交于 2020-04-12 06:33:07
问题 I would like to draw some Geodesic Polyline(great circle line) between points on Earth using Satellite Flyover map type. // in viewDidLoad() mapView.mapType = .satelliteFlyover let geodesic = MKGeodesicPolyline(coordinates: [route.airport1, route.airport2], count: 2) self.mapView.addOverlay(geodesic) // rendering method func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { guard let polyline = overlay as? MKPolyline else { print("else??") return

Open an Alert asking to choose App to open map with

試著忘記壹切 提交于 2020-04-08 04:38:32
问题 I have a view controller with map kit integrated. I need to shoot an alert before opening that map, asking to choose from all similar applications of maps to open it with. For instance, if google maps app is installed in my iPhone, there should be an option for it, along with the default mapkit view. Is there a possibility to achieve this functionality which scans every similar app from iphone and returns the result as options to open map with. 回答1: You can create an array of checks to map

Open an Alert asking to choose App to open map with

本秂侑毒 提交于 2020-04-08 04:37:08
问题 I have a view controller with map kit integrated. I need to shoot an alert before opening that map, asking to choose from all similar applications of maps to open it with. For instance, if google maps app is installed in my iPhone, there should be an option for it, along with the default mapkit view. Is there a possibility to achieve this functionality which scans every similar app from iphone and returns the result as options to open map with. 回答1: You can create an array of checks to map

Open an Alert asking to choose App to open map with

爱⌒轻易说出口 提交于 2020-04-08 04:36:26
问题 I have a view controller with map kit integrated. I need to shoot an alert before opening that map, asking to choose from all similar applications of maps to open it with. For instance, if google maps app is installed in my iPhone, there should be an option for it, along with the default mapkit view. Is there a possibility to achieve this functionality which scans every similar app from iphone and returns the result as options to open map with. 回答1: You can create an array of checks to map

How to streamline multiple coordinate poly line entries in MKMapKit

匆匆过客 提交于 2020-04-05 06:35:22
问题 I am trying to add multiple poly lines onto a map using mkmapkit. These poly lines indicate walking zones in my area. The problem is that my code is too bulky for a large amount of walking zones. At the moment my code only indicates 2 walking routes but for instance if I want to add 100 or 1000 walking routes the code would be massive. I'm sure there is a way I could stream line this code so I could add in multiple walking zones with a lot less code but in not too sure the best way to go

Polylines are disappearing when zoom closely

二次信任 提交于 2020-03-24 07:21:12
问题 I created seven different polylines. However some of them are disappearing when I zoom in closely. Why it is happening? How can I prevent this? Here is my polyline renderer: func mapView(_ mapView: MKMapView, rendererFor overlay: MKOverlay) -> MKOverlayRenderer { let renderer = MKPolylineRenderer(polyline: overlay as! MKPolyline) renderer.strokeColor = UIColor(red: 1, green: 1, blue: 1, alpha: 0.9) renderer.lineWidth = 2.2 return renderer } //Thousands of parameters sending as a parameter

Is it possible to customize cluster image in iOS 11?

ε祈祈猫儿з 提交于 2020-03-24 01:01:10
问题 I'm using iOS 11 new APIs and I have been successful in making cluster appear. Now, I'm trying to change cluster image providing a custom image. Since I created this custom annotation view: class PlaceView: MKAnnotationView { override var annotation: MKAnnotation? { willSet { guard let place = newValue as? Place else {return} clusteringIdentifier = Place.type image = place.image } } I tried to add this line inside willSet block: cluster?.image = UIImage(named: "Cluster") but it didn't work.