mkpolyline

Mapkit is using too much CPU in IOS 13

我的未来我决定 提交于 2019-12-07 19:47:49
问题 Recently my iOS app starting crashing frequently after some users updated to iOS 13.x (it doesn't exhibit the problem in iOS 12.x) I am using Mapkit to render some MKPolygons and MKPolylines. The MKPolylines get removed and re-added to the MKMapView around 10 times per second (that's because my GPS is giving me new lat/longs at 10Hz). I profiled my app in iOS 12.x and it is using around 15% to 30% of CPU resources (iPad Mini 4). I did the same profiling in iOS 13.1.2 and 13.1.3, and the CPU

Identify when MKRoutestep finishes

喜夏-厌秋 提交于 2019-12-07 13:53:02
问题 I am trying to implement a turn by turn navigation system in iOS using MKDirections API. I am able to get the directions of the route and can draw the polyline on the map, and when navigation starts the app start showing the instructions using the MKRouteStep object in Steps array. Now the problem is , since the distance in the MKRouteStep object is the distance that the user covers while traversing the path of the step I am unable to identify how to calculate this distance. Is there any way

Mapkit is using too much CPU in IOS 13

折月煮酒 提交于 2019-12-06 15:24:34
Recently my iOS app starting crashing frequently after some users updated to iOS 13.x (it doesn't exhibit the problem in iOS 12.x) I am using Mapkit to render some MKPolygons and MKPolylines. The MKPolylines get removed and re-added to the MKMapView around 10 times per second (that's because my GPS is giving me new lat/longs at 10Hz). I profiled my app in iOS 12.x and it is using around 15% to 30% of CPU resources (iPad Mini 4). I did the same profiling in iOS 13.1.2 and 13.1.3, and the CPU consumption went up to around 150% (there are 2 CPU cores). If I remove the code that renders the 2

MKPolyLineRenderer change color without removing overlay

假装没事ソ 提交于 2019-12-06 11:38:13
问题 I am developing an application that almost replicates Apple maps application behavior. When i touch a route, i need to change its color to blue and change the other ones colors to gray. Is there an efficient way to accomplish this without having to remove the overlays and adding them again ? Thanks. 回答1: Yes: Make sure your annotation view has enabled = YES . Implement -[MKMapViewDelegate mapView:didSelectAnnotationView:] . In that callback, get view and change its properties. 来源: https:/

Polyline not drawing from user location (blue dot)

好久不见. 提交于 2019-12-06 09:57:02
问题 - (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D currentLocation; currentLocation.latitude = self.mapView.userLocation.location.coordinate.latitude; currentLocation.longitude = self.mapView.userLocation.location.coordinate.longitude; CLLocationCoordinate2D otherLocation; otherLocation.latitude = [lati doubleValue]; otherLocation.longitude = [longi doubleValue]; MKPointAnnotation *mka = [[MKPointAnnotation alloc]init]; mka.Coordinate = otherLocation; mka.title = @"!"; [self

MKRoute update MKPolyline Overlay when current Location changes

拥有回忆 提交于 2019-12-05 17:51:27
I did google a lot but couldn t get this to work. In my MKMapView I have a custom MKAnnotationView that I can place anywhere and also that dot that is representing my current location. I can do "show directions" calculate MKDirections between my custom annotation and my current position and draw a MKPolyline overlay to show the MKRoute. So far so good. If I am moving now towards my custom annotation, the Polyline Overlay does not update, does not substract the distance I already traveled. I thought I have to redraw the polyline. In the CLLocation delegate -(void)locationManager:

Dotted line on map view

放肆的年华 提交于 2019-12-05 01:21:05
I can create a line between two points fairly easy with the below code (part of it anyways) How could I make the line dotted instead of solid? Also would it be possible to change the opacity the longer the line is? - (MKOverlayRenderer *)mapView:(MKMapView *)mapView rendererForOverlay:(id < MKOverlay >)overlay { MKPolylineRenderer *renderer =[[MKPolylineRenderer alloc] initWithPolyline:overlay]; renderer.strokeColor = [UIColor orangeColor]; renderer.lineWidth = 3.0; return renderer; } You can use the lineDashPattern property to create the pattern you want for the line. MKPolylineRenderer is a

Polyline not drawing from user location (blue dot)

南笙酒味 提交于 2019-12-04 18:08:30
- (void)viewDidLoad { [super viewDidLoad]; CLLocationCoordinate2D currentLocation; currentLocation.latitude = self.mapView.userLocation.location.coordinate.latitude; currentLocation.longitude = self.mapView.userLocation.location.coordinate.longitude; CLLocationCoordinate2D otherLocation; otherLocation.latitude = [lati doubleValue]; otherLocation.longitude = [longi doubleValue]; MKPointAnnotation *mka = [[MKPointAnnotation alloc]init]; mka.Coordinate = otherLocation; mka.title = @"!"; [self.mapView addAnnotation:mka]; self.mapView.delegate = self; MKMapPoint *pointsArray = malloc(sizeof

How to make custom MKPolyline in SWIFT with additional argument - color

☆樱花仙子☆ 提交于 2019-12-04 03:18:18
问题 Can any help me with making custom MKPolyline with additional argument Color? CustomPolyline.swift import Foundation import MapKit class CustomPolyline : MKPolyline { let coordinates: UnsafeMutablePointer<CLLocationCoordinate2D> let count : Int = 0 let color : String = "ff0000" init(coordinates: UnsafeMutablePointer<CLLocationCoordinate2D>, count: Int, color: String) { self.coordinates = coordinates self.count = count self.color = color } } Init Polyline = CustomPolyline(coordinates: &Path,

MKPolyline strange rendering related with zooming in MapKit

99封情书 提交于 2019-12-03 13:17:22
问题 I have very simple View Controller to demonstrate this strange rendering behavior of MKPolyline. Nothing special just normal api calls. import UIKit import MapKit class ViewController: UIViewController, MKMapViewDelegate { @IBOutlet weak var map: MKMapView! override func viewDidLoad() { super.viewDidLoad() map.delegate = self } override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let p1 = CLLocationCoordinate2D(latitude: 51, longitude: 13) var coords = [ p1,