mkpointannotation

Swift MKPointAnnotation custom Image

删除回忆录丶 提交于 2019-12-10 19:05:37
问题 I try to create a custom "badget" for my MKPointAnnotation in swift, but it fails as MKPointAnnotation does not have any property like image var information = MKPointAnnotation() information.coordinate = location information.title = "Test Title!" information.subtitle = "Subtitle" information.image = UIImage(named: "dot.png") //this is the line whats wrong Map.addAnnotation(information) Anyone figured out a swift like solution for that? 回答1: func mapView(mapView: MKMapView, viewForAnnotation

How to update information on MKPinAnnotationView?

坚强是说给别人听的谎言 提交于 2019-12-09 06:49:25
I've had some past experience using MKMapView and MKPointAnnotation , which I used to put some pin on a map. This time I am trying to go one step further and use MKPinAnnotationView , to write a label along with some of the pins. Unfortunately, it doesn't all work as I expect. Here is what I want to do: I have a map (an MKMapView object) and when I touch it, I put a pin at the touch point, then some computation is performed and this gives me a second point on the map. I put a second pin on the map (located at the second point), on this last pin I want to put a label, say "Hello Second!", but

Saving map pins to array, Swift

荒凉一梦 提交于 2019-12-07 18:45:46
问题 I am creating a map type application, once the user presses a button a pin is dropped to the map at their current location. I am trying to save map pins to an array so that they remain once the app is closed. Here is my code so far: func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let location = locations.last let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude) let region =

Saving map pins to array, Swift

不问归期 提交于 2019-12-06 08:14:32
I am creating a map type application, once the user presses a button a pin is dropped to the map at their current location. I am trying to save map pins to an array so that they remain once the app is closed. Here is my code so far: func locationManager(manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) { let location = locations.last let center = CLLocationCoordinate2D(latitude: location!.coordinate.latitude, longitude: location!.coordinate.longitude) let region = MKCoordinateRegion(center: center, span: MKCoordinateSpan(latitudeDelta: 0.004, longitudeDelta: 0.004)) self

Identify MKPointAnnotation in mapView

无人久伴 提交于 2019-12-06 05:52:41
问题 I have at least 100 diferents Points ... how can associate each point with the position in my 'listOfPoints' assigning a tag in the position associated in viewForAnnotation . Here i add my Points, some events will have the same title. var listOfPoints : Array<Events> = [] // List Of all events //add points to map for (index, mPoints) in enumerate(listOfPoints) { var point: MKPointAnnotation! = MKPointAnnotation() var location = CLLocationCoordinate2D(latitude: mPoints.latitude, longitude:

Identify MKPointAnnotation in mapView

北城余情 提交于 2019-12-04 10:57:35
I have at least 100 diferents Points ... how can associate each point with the position in my 'listOfPoints' assigning a tag in the position associated in viewForAnnotation . Here i add my Points, some events will have the same title. var listOfPoints : Array<Events> = [] // List Of all events //add points to map for (index, mPoints) in enumerate(listOfPoints) { var point: MKPointAnnotation! = MKPointAnnotation() var location = CLLocationCoordinate2D(latitude: mPoints.latitude, longitude: mPoints.longitude) point.coordinate = location point.title = mPoints.name point.subtitle = mPoints.address

How to get Apple Maps App (not MapKit) to add an annotation?

旧时模样 提交于 2019-12-02 06:17:15
It's quite easy to add an annotation to a MapKit view which is inside your app . theMap: MKMapView! let pa = MKPointAnnotation() pa.title = "title!!" etc theMap.addAnnotation(pa) But how the heck do you make the Maps App add an annotation?? Here's exactly how to open the Maps App to a certain address.. func appleMapApp() { quickAddressText = "123 Smith St 90210" let bottomText = "This shows at BOTTOM Of Maps App screen." let g = CLGeocoder() g.geocodeAddressString(quickAddressText) { placemarks, error in if let found = placemarks?.first, let lok = found.location { let p = MKPlacemark

Longer subtitles in MapView annotations (swift)

吃可爱长大的小学妹 提交于 2019-12-01 11:36:12
I have a mapView with annotations displaying titles and subtitles. The subtitles are sometimes longer than the width of the annotation, so I am wondering if i can make them multiline? It's coded like this so far: func annotate(newCoordinate, title: String, subtitle: String) { let annotation = MKPointAnnotation() annotation.coordinate = newCoordinate annotation.title = title annotation.subtitle = subtitle self.map.addAnnotation(annotation) } Then i have a few options set in func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? {...} which are not

MKPointAnnotations touch event in swift

寵の児 提交于 2019-11-30 15:21:05
问题 I would like to know if anyone can tell me how I can touch a pin on the map in the form of MKPointAnnotations . I would like to click the pin on the map and go to another view by bringing back the variables of the pin that I have preset . Can anyone explain me this thing in Swift ? thanks Edit with code: class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var mappa: MKMapView! override func viewDidLoad() { super.viewDidLoad() var location : CLLocationCoordinate2D =

Swift 3 Add custom annotation pin to MKMapSnapShotter snapshot

痴心易碎 提交于 2019-11-30 13:57:56
I'm learning Swift 3 on my own, and my current learning project involves allowing the user to snap a photo and get a map snapshot with the current location pinned. I've relied on this answer from Aug 2015 and this answer from Jun 2016 for guidance, but I still can't find the right path. Right now, I can... Get the photo from the buffer Get a map snapshot But I just can't place the pin. I know that my code is incomplete and ineffective -- so this is more than just a debugging question. Here is what I've been working with (as well as many variations based on the links above): let snapShotter =