mkpointannotation

MapKit in Swift, Part 3 - MKPointAnnotation, addAnnotations

亡梦爱人 提交于 2021-01-28 21:34:32
问题 I'm trying work with Map Kit in Swift. I try to display the area on the map, some pins (MKPointAnnotation) and the current position. I decided to extend the class MKPointAnnotation - add a category. Class MyAnnotation.swift: import UIKit import MapKit class MyAnnotation: MKPointAnnotation { var category = Int() } I made an array of tuples to store information about the objects. In the loop I process all the elements of this array and make from it an array MyAnnotation . Then, I try to display

Longer subtitles in MapView annotations (swift)

廉价感情. 提交于 2020-01-11 06:58:10
问题 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

How to update information on MKPinAnnotationView?

徘徊边缘 提交于 2020-01-03 00:54:11
问题 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

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

て烟熏妆下的殇ゞ 提交于 2019-12-31 03:57:29
问题 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) {

how to set up array for multi annotations with swift

梦想与她 提交于 2019-12-30 01:20:25
问题 How should the array below be set. Im trying to add multiple annotations onto my map. I was able to find the code below on stackoverflow but they did not show how to set up the array. var objects = [ //how should the array be setup here ] for objecters in objects!{ if let latit = objecters["Coordinates"]["Latitude"]{ self.latitudepoint = latit as! String self.map.reloadInputViews() } else { continue } if let longi = objecters["Coordinates"]["Longitude"]{ self.longitudepoint = longi as! String

Swift 3 Add custom annotation pin to MKMapSnapShotter snapshot

不打扰是莪最后的温柔 提交于 2019-12-18 16:46:05
问题 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

Show Annotation Title and SubTitle in Custom MKPinAnnotationView

☆樱花仙子☆ 提交于 2019-12-13 05:52:19
问题 I am using MKPinAnnotationView inside my App. I am setting MapView object as delegate, and using this code for customising my AnnotationView func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { if annotation is MKUserLocation { //return nil so map view draws "blue dot" for standard user location return nil } let reuseId = "pin" var pinView = mapView.dequeueReusableAnnotationViewWithIdentifier(reuseId) as? MKPinAnnotationView if pinView == nil {

Swift - adding a button to my MKPointAnnotation

不想你离开。 提交于 2019-12-11 12:00:00
问题 On Swift 1.2 : I'd like to add a button to my annotations on the map. First tap on pin shows user's id, and this is working, but then, by pressing the button, I want to send the user to a detail view controller. you can have an idea of what I'm looking for here and here tried to apply those solutions, but I think I'm missing something. This is another example of what I'm seeking this is my class declaration: import UIKit import MapKit import CoreLocation import Parse class MapViewController:

Add extra detail to MKPointAnnotation other than title and subtitle

混江龙づ霸主 提交于 2019-12-11 04:31:26
问题 I wish to pass informations from a Pin annotation to another viewController.I can pass the title and subtitle of the annotation but I need to pass some extra information along with these. Is there a way to add extra information to a MKPointAnnotation other than just title and subtitle? here I have the pin title and subtitle set so it appears on the map: var zoopin = MKPointAnnotation() zoopin.coordinate = zoo zoopin.title = "The zoo" zoopin.subtitle = "hello this is the zoo" mapView

MKPointAnnotation add extra property

╄→尐↘猪︶ㄣ 提交于 2019-12-11 03:47:40
问题 Is it possible to add an extra property to MKPointAnnotation ? At the moment there is coordinate , title , and subtitle . Is it possible to add a url property which can be accessed within -(MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation{ } , just like I can access [annotation title]; ? 回答1: Just make an MKPointAnnotation subclass. Delete all the methods out of the .m file, and add this to your .h file: @property (nonatomic, strong) NSURL *url;