mapkitannotation

How to set a custom annotations for all points except for user location?

≯℡__Kan透↙ 提交于 2021-01-29 14:30:53
问题 After the authorization checks, to obtain the user location, I am calling this CLLocation delegate function: func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { guard let latestLocation = locations.first else { return } if currentCoordinate == nil { zoomToLocation(with: latestLocation.coordinate) } currentCoordinate = latestLocation.coordinate } And then I zoom onto the user's location: func zoomToLocation(with coordinate: CLLocationCoordinate2D) {

Preventing annotation deselection in MKMapView

爷,独闯天下 提交于 2020-01-25 02:56:32
问题 I have a situation in my app where I want to disable annotation deselection (other than when selecting another), so when I tap anywhere that is not an annotation view, it should leave the currently selected annotation as is. If I tap on another annotation view, it should select that one and deselect the other. I was hoping to find something along the lines of a willDeselectAnnotationView in the MKMapViewDelegate or an isDeselected in MKAnnotationView , but there's unfortunately no such thing.

How to fix custom Point Annotations from disappearing from overlap?

梦想的初衷 提交于 2019-12-24 11:27:41
问题 Attempting to show custom point annotations from MapKits local search. When the annotations first load on the map all of them show, but then the overlapping ones disappear. And they only reappear when you zoom in on the area. Many stack solutions have stated to user view?.displayPriority = .required . But for some reason this line of code doesn't work. Local Search Function on button press @IBAction func groceryLocalSearch(_ sender: Any) { self.localStoresArray.removeAll() self.LocalMapKit

Remove MKAnnotationView Default Callout From View

北战南征 提交于 2019-12-24 06:47:35
问题 I am trying to prevent MKMapKit from presenting the default annotation callout when tapping on a marker displayed on a MKMapView without blocking the delegate call / interaction of the annotation (seen below). - (void)mapView:(MKMapView *)mapView didSelectAnnotation:(MKAnnotationView *)view { // Custom callout initialized & presented here . . . } I understand you may disable the callout from showing entirely someAnnotationView.canShowCallout = NO; or (more of a hackish approach) not setting

Change color pin iOS 9 Mapkit

可紊 提交于 2019-12-21 21:53:51
问题 I don't know how to change the code for the pin color in iOS 9 (because lately Apple changed the code for it), and I'm still new in Swift. So, I don't know how to integrate pinTintColor in my code now. Please find below my code: import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() let annotation = MKPointAnnotation() let latitude:CLLocationDegrees = 40.5 let longitude

How do I show MKOverlay above MKAnnotations?

元气小坏坏 提交于 2019-12-19 06:18:08
问题 I'm trying to use an MKOverlay (specifically an MKPolyline ) to show a route on the map. However, I need the route to show up above my existing pins (custom MKAnnotationView s). Is there a good way to bring the MKPolyline to the front above the pins? 回答1: It might be useful to investigate the annotation layer's zOrder property. Sending the annotations backwards in your superview's hierarchy may help you achieve the effect needed. Changing your annotation z-axis position should probably be

MapKit Annotations Disappearing

半腔热情 提交于 2019-12-18 04:52:35
问题 I have an array of latitudes and another array of longitudes that I add to an array of type CLLocationCoordinate2D. I then use the new array to annotate multiple points on the map. Some, or most, or maybe even all of the annotations are displaying on the map but as I zoom in (yes, zoom IN), some of the annotations disappear, then come back, or dont. Any ideas on how to keep them all visible? This is behavior I would expect while zooming out, not in. Here is the code i'm using for what i've

Retrieving data from Firebase and storing as annotations on a map

丶灬走出姿态 提交于 2019-12-12 04:17:43
问题 I've successfully managed to store data to my Firebase database from a form I created in a view controller but now need to retrieve the data to display as annotations on a map on a second view controller but do not know how I should go about doing this task after searching and finding nothing online. Here is my working code that saves my data successfully to the Firebase database: import UIKit import CoreLocation import Firebase class AddSightingViewController: UIViewController { @IBOutlet

MapKit adding multiple annotations from core data

爱⌒轻易说出口 提交于 2019-12-11 23:07:26
问题 This is my code. It loops for the number records in the database but only retrieves the first records lat and lon. func fetch() { let appDel: AppDelegate = UIApplication.sharedApplication().delegate as! AppDelegate let context: NSManagedObjectContext = appDel.managedObjectContext! let freq = NSFetchRequest(entityName: "Mappoints") let fetchResults = try! context.executeFetchRequest(freq) as! [NSManagedObject] self.mapView.delegate = self myData = fetchResults myData.count for _ in myData {

iOS MapKit custom callout with image and text on top of a pin programmatically using swift

萝らか妹 提交于 2019-12-11 06:07:02
问题 I am trying to show a custom call out on top of pin in the map. It is required that I show an image with some text on top of pin as my call out. The code I wrote produces the following output. However, my desired output looks like this: How can I achieve my desired output ? Please note that the bubble is an image asset which has to be used, I know how to draw a bubble using CAShapeLayer but that does not accomplish what I want. Here is the code so far. // methods for Custom annotations func