mkpolyline

Draw polyline using Swift

非 Y 不嫁゛ 提交于 2019-11-29 08:48:58
问题 I'm trying to get an understanding of how to draw polylines using Swift. I've looked at the documentation, referenced some tutorials, and checked out some other SO posts, but I still can't get the thing to draw a line on my map. Here's my code. Anyone tell me what I'm doing wrong here? import UIKit import MapKit class FirstViewController: UIViewController { @IBOutlet weak var map: MKMapView! override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) let location =

UnsafeMutablePointer in swift as replacement for properly sized C Array in Obj-C

大城市里の小女人 提交于 2019-11-29 02:51:15
问题 How can I interact with functions in swift that used to take sized C arrays? I read through Interacting with C APIS and still can't figure this out. The documentation for the coords parameter of func getCoordinates(_ coords:UnsafeMutablePointer<CLLocationCoordinate2D>,range range: NSRange) states: "On input, you must provide a C array of structures large enough to hold the desired number of coordinates. On output, this structure contains the requested coordinate data." I tried several things,

How to detect taps on MKPolylines/Overlays like Maps.app?

吃可爱长大的小学妹 提交于 2019-11-28 15:50:12
问题 When displaying directions on the built-in Maps.app on the iPhone you can "select" one of the usually 3 route alternatives that are displayed by tapping on it. I wan't to replicate this functionality and check if a tap lies within a given MKPolyline. Currently I detect taps on the MapView like this: // Add Gesture Recognizer to MapView to detect taps UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(handleMapTap:)]; // we require all gesture

latitude and longitude points from MKPolyline

青春壹個敷衍的年華 提交于 2019-11-28 08:04:29
I am trying to figure out a way to get all the latitude and longitude points from a MKPolyline drawn on a MKMapView on an iOS app. I know the MKPolyline does not store latitude and longitude points, but I am looking for a way to build an array of lat and long the MKPolyline would touch on the map. Anybody has specific possible solutions on this? Thank you EDIT: After seeing the first response (thank you) I think I need to explain better what my code is doing: first I call " calculateDirectionsWithCompletionHandler " on a MKDirections object I get back MKRoute object which has a " polyline "

MKPolylineRenderer produces jagged, unequal paths

折月煮酒 提交于 2019-11-28 03:19:29
问题 I am using the iOS 7 MapKit APIs to produce 3D camera movements on a map that displays an MKDirectionsRequest-produced path. The path is rendered by MKOverlayRenderer like so: -(void)showRoute:(MKDirectionsResponse *)response { for (MKRoute *route in response.routes) { [self.map addOverlay:route.polyline level:MKOverlayLevelAboveRoads]; } } - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay { MKPolylineRenderer *renderer = [[MKPolylineRenderer

latitude and longitude points from MKPolyline

我的未来我决定 提交于 2019-11-27 02:03:48
问题 I am trying to figure out a way to get all the latitude and longitude points from a MKPolyline drawn on a MKMapView on an iOS app. I know the MKPolyline does not store latitude and longitude points, but I am looking for a way to build an array of lat and long the MKPolyline would touch on the map. Anybody has specific possible solutions on this? Thank you EDIT: After seeing the first response (thank you) I think I need to explain better what my code is doing: first I call "

How to use MKPolylineView in Swift

ぃ、小莉子 提交于 2019-11-26 22:01:29
问题 I want to draw polyline in my Swift app. Swift code class MapViewController: UIViewController, MKMapViewDelegate { @IBOutlet var theMapView: MKMapView override func viewDidLoad() { super.viewDidLoad() setMapView() } func setMapView() { //theMapView.zoomEnabled = false //theMapView.scrollEnabled = false theMapView.rotateEnabled = false // var lat: CLLocationDegrees = 37.586601 var lng: CLLocationDegrees = 127.009381 // var latDelta: CLLocationDegrees = 0.008 var lngDelta: CLLocationDegrees = 0