mapkit

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

Get center coordinates from MapKit and display in UILabel

青春壹個敷衍的年華 提交于 2019-12-04 10:25:40
I'm developing an iOS app using XCode 7.2 and Swift 2.1, and I've successfully implemented a MapKit map in my app. The map loads perfectly and centers on the user's current location. Now I want to retrieve the center coordinates should the user move the center of the map to a new location. This new location's coordinates will be "captured" on the press of a button (see the "Set Grid Reference" button in the attached gif) and be displayed in a label. Move from A to B and set new center coordinates The closest I've come to an answer is here , and I've implemented that code, but I still can't

MapKit multiple pins same coordinates, different info selection

不想你离开。 提交于 2019-12-04 10:17:21
I have the following situation: - 3 pins with same coordinates but different title and info - on map there is ony one pin It is possible to tap multiple times on that pin and the annotation displayed to be: - first tap -> the annotation for pin 1 - second tap -> the annotation for pin 2 - third tap -> the annotation for pin 3 - fourth tap -> the annotation for pin 1 Do you have any ideas how should I implement it? You can implement the didSelectAnnotationView delegate method and select the "correct" annotation yourself depending on what the last "correct" selection was. If you only have these

MapView detect scrolling

纵然是瞬间 提交于 2019-12-04 10:14:20
I'm wishing that MKMapView inherited from UIScrollView just like UITableView and UICollectionView are. This way you can override the UIScrollView delegate methods and do what you need to do. I've found the method of attaching a pan gesture to the MapView like so: UIPanGestureRecognizer* mapPanGestureRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(mapPanGestureHandler:)]; [mapPanGestureRecognizer setDelegate:self]; [self.mapView addGestureRecognizer:mapPanGestureRecognizer]; This works fairly well except for the fact that the mapView has a deceleration element

How to create CGPathRef from Array of points

江枫思渺然 提交于 2019-12-04 09:31:21
问题 Hi all i've been working in a map application, Where i needed to draw the route between two locations, I've got route coordinates too (using google Direction api) and kept it in an array, Now all i need to do is creating a path from the array of points, later i will use the path with MKOverlayPathView for creating real routes on the map. Here my problem is how to create a CGPathRef from the array of coordinates, Or any other way to do the same operation Thanks in Advance 回答1: Assuming the

Performance issues with MapKit on iOS6

前提是你 提交于 2019-12-04 09:20:49
After updating to iOS 6 I have noticed sever performance decreases when panning or zooming a MKMapView with multiple overlays. An app I created has approximately 600 polygon overlays of various colours, and ran lag-free (even on older iOS devices) on iOS 5, now runs extremely laggily (when zooming & panning) on iOS 6, even on the latest devices. My hunch is that this is due to the fact the device has to actually dynamically create the map (since its vector based) rather than just display tiles onscreen. Has anyone got any ideas to reduce the lag experienced when panning or zooming the map?

MKAnnotationView layer is not of expected type: MKLayer

邮差的信 提交于 2019-12-04 09:08:22
问题 So my code works fine but my logger is riddled with this message. Is there a way to get rid of it or suppress it? PostAnnotation.swift class PostAnnotation: MKPointAnnotation { //MARK: properties let post: Post //MARK: initialization init(post: Post) { self.post = post super.init() self.coordinate = CLLocationCoordinate2D(latitude: post.latitude, longitude: post.longitude) self.title = post.title self.subtitle = post.timeString() } } Adding the annotation let annotation = PostAnnotation(post:

VectorKit crash reports with MKMapSnapshotter on iOS

ぃ、小莉子 提交于 2019-12-04 08:46:54
问题 I'm getting different kind of crash reports related to VectorKit and MKMapSnapShotter . Crashes occur pretty random, but it seems like they happen most when returning from the background. The device does not send out any memory warnings before it happens. What's happening here? I'm using: if (!_snapshotQueue) { _snapshotQueue = dispatch_queue_create("com.bestappever.snapshot", DISPATCH_QUEUE_SERIAL); } [_snapshotter cancel] _snapshotter = [[MKMapSnapshotter alloc] initWithOptions:options]; _

How to detect when MKUserTrackingBarButtonItem is used

两盒软妹~` 提交于 2019-12-04 08:05:31
I'm currently trying to find a way to detect when the MKUserTrackingBarButtonItem is used, other than deal with the mapView:didUpdateUserLocation: delegate method. I tried to setAction of the MKUserTrackingBarButtonItem to call my function (check this thread ), but of curse it removes the updating location action, which I don't want. I don't find any delegate method triggered :/ Thanks for any idea. If your MKUserTrackingBarButtonItem has been assigned a MKMapView to operate on then the map view's delegate will receive mapView:didChangeUserTrackingMode:animated: when the tracking mode is

How to overlay a circle on an iOS map

拈花ヽ惹草 提交于 2019-12-04 07:32:18
I've got a radius and a location. This is how I'm trying to get the bounding rectangle of the circle. - (MKMapRect)boundingMapRect{ CLLocationCoordinate2D tmp; MKCoordinateSpan radiusSpan = MKCoordinateRegionMakeWithDistance(self.coordinate, 0, self.radius).span; tmp.latitude = self.coordinate.latitude - radiusSpan.longitudeDelta; tmp.longitude = self.coordinate.longitude - radiusSpanSpan.longitudeDelta; MKMapPoint upperLeft = MKMapPointForCoordinate(tmp); MKMapRect bounds = MKMapRectMake(upperLeft.x, upperLeft.y, self.radius * 2, self.radius * 2); return bounds; } MKMapRectMake(...) seems to