mapkit

How to reorder MKMapView annotations array

心不动则不痛 提交于 2019-11-28 14:26:20
I'd like to reorder the array of annotations shown on a map in order to create a next/prev button for quickly cycling through all annotations (sorted by date) using a simple iterator. As far as I see the annotations array used as a store [worldmap annotations] is not mutable and therefore I cannot reorder it. I tried the following to create a temporary copy of the annotations array, sort it by date and re-attach it. ( worldmap is my MKMapView object) //COPY NSMutableArray *annotationSort = [[NSMutableArray alloc]initWithArray:[worldmap annotations]]; //SORT [annotationSort

Using a custom annotation when adding it to map

两盒软妹~` 提交于 2019-11-28 12:13:17
问题 I'm having trouble accessing my custom annotation class when adding it to a mapview. I have the custom class working properly but i when i add it to the map i'm not sure how to access the custom annotation through this delegate: - (MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation i've tried looking online and havent found anything. any help would be great. Its called like this: CLLocationCoordinate2D coords = CLLocationCoordinate2DMake(shops

custom annotation apple mapkit

别说谁变了你拦得住时间么 提交于 2019-11-28 11:32:55
问题 I am trying to assign two custom annotations, one called "arsenal.png" and one called "chelsea.png" Using apple mapkit framework, xcode 7. Need assistance with code to achieve the customized markers. here is my implementation file: // TrucksViewController.m #import "TrucksViewController.h" #import "Annotation.h" @interface TrucksViewController () @end //Wimbledon Coordinates #define WIMB_LATITUDE 51.434783; #define WIMB_LONGITUDE -0.213428; //Stadium Coordinates #define ARSENAL_LATITUDE 51

why self.locationManager stopUpdatingLocation doesn't stop location update

牧云@^-^@ 提交于 2019-11-28 10:44:20
Problem : It seems I can't stop Core Location from sending updates to my app / tracking. What am I doing : In my viewWillAppear I call self.locationManager and pass it to a method to show user's location on the map (an instance of MKMapView ). The getter is overridden to check for availability of the serive, to see whether its authorized. If so, it allocs/inits and startMonitoringSignificantLocationChanges and returns . In viewDidDisappear , I call [self.locationManager stopUpdatingLocation] . But still I can see the location icon in the status bar. Even when I terminate the app by double

kCLErrorDomain error 2 after geocoding repeatedly with CLGeocoder

时间秒杀一切 提交于 2019-11-28 10:43:21
I have a search bar in my application that the user can type an address into, and it will come up with the geocoded result. The result updates as the user types, according to the following code: - (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText { ... if (self.geocoder.geocoding) [self.geocoder cancelGeocode]; [self.geocoder geocodeAddressString:searchText completionHandler:^(NSArray *placemarks, NSError *error) { if (error != nil) { NSLog(@"ERROR during geocode: %@", error.description); return; } //update the view }]; } This works for the first few characters the

How to make the union between two MKCoordinateRegion

依然范特西╮ 提交于 2019-11-28 10:24:16
I'm trying to do the union between two MKCoordinateRegion. Does anybody have an idea on how to do this? There is a MKMapRectUnion function which accepts two MKMapRects so you could first convert each MKCoordinateRegion to an MKMapRect and then call that function (and convert the result back to an MKCoordinateRegion using the MKCoordinateRegionForMapRect function). The conversion method might look like this: - (MKMapRect)mapRectForCoordinateRegion:(MKCoordinateRegion)coordinateRegion { CLLocationCoordinate2D topLeftCoordinate = CLLocationCoordinate2DMake(coordinateRegion.center.latitude +

Slight zoom on MKCoordinateRegion?

我们两清 提交于 2019-11-28 10:24:12
I am zooming an MKMapView to fit the bounding region of a collection of pins, however when the pins are displayed I have noticed that the zoom could ideally do with being a little tighter. My proposed solution to this was to make the region deltas slightly smaller: // SMALL ZOOM region.span.latitudeDelta = (upper.latitude - lower.latitude) * 0.9; region.span.longitudeDelta = (upper.longitude - lower.longitude) * 0.9; However I have noticed that fine adjustments don't seem to translate to a small zoom increase, is there some form of snapping on the zoom? Really small values work, as do really

iOS app getting throttled from local searches

那年仲夏 提交于 2019-11-28 09:11:38
I am implementing autocomplete (one search per new character added) in an app that searches for addresses, and I keep getting MKErrorDomain error 3 , which is MKErrorLoadingThrottled . This error, according to Apple dev , occurs when The data was not loaded because data throttling is in effect. This error can occur if an app makes frequent requests for data over a short period of time. I know exactly how many requests are being made, one for each new charachter in the search query (just like you would expect autocomplete to work). Sure, I am a fast typer, but being able to hit the limit after

MKMapView doesn't zoom correctly while user tracking mode is MKUserTrackingModeFollowWithHeading

蓝咒 提交于 2019-11-28 08:34:06
I created a test project with few lines of code and with two components: MKMapView and UIButton . I ticked mapView option - Shows user location . Also I defined an action for the button, it zooms the map to user location. Here is code from controller: - (void)viewDidAppear:(BOOL)animated { [super viewDidAppear:animated]; self.mapView.userTrackingMode = MKUserTrackingModeFollowWithHeading; self.mapView.delegate = self; } - (IBAction)changeRegion:(id)sender { MKCoordinateRegion region = MKCoordinateRegionMakeWithDistance(self.mapView.userLocation.coordinate, 200.0f, 200.0f); [self.mapView

iPhone MapKit: Annotation images get reset back to pins

拟墨画扇 提交于 2019-11-28 08:22:53
问题 I'm adding several annotations to a MapView and using a custom image instead of the default pins. I am using the viewForAnnotation delegate method to set the custom image like this: view.image = [UIImage imageNamed:@"placemark.png"]; And I've also tried: [(MKPinAnnotationView *)view setImage:[UIImage imageNamed:@"placemark.png"]]; Now, these both set the image just fine. But when an annotation is either tapped or the mapType changes to Satellite or Hybrid, it resets back to the red pin image.