mkannotation

Problems with MapView Pin Annotation - Pin loses color when map is zoomed/panned/region changes

杀马特。学长 韩版系。学妹 提交于 2019-12-09 01:31:26
问题 I have a mapview that displays locations of cash points. Annotations are dropped and the callout can be clicked on to go to a page with more detail about that location. There are two categories of cashpoint, free and paid, free cashpoint pins are green and the other red. When the pins drop they are the correct colours. Everything works fine untill i zoom to user location or other areas of the map then when i go back to the pins they have lost their colour formatting and are all the original

iphone mapview bring first and last annotation to the front

流过昼夜 提交于 2019-12-08 16:45:58
问题 I need some code which can be used outside of the mk* functions. I need to run my custom function to bring the FIRST and LAST markers in an array to the front. (so on top of all the other markers on my screen). I have tried [self.view bringSubviewToFront:[[mapView annotations]objectAtIndex: 0]]; I have used [[mapView annotations]objectAtIndex: 0] in my code and that works, but it crashes when I try to bring this to the front. Am I accessing the wrong layer or something? thanks for any help.

Zoom MKMapview to closest two MKAnnotations for current user location

Deadly 提交于 2019-12-08 13:28:56
问题 What is the best way to zoom an MKMapview to closest two or three MKAnnotations for current user location? I have a list of GPS coordinates (328 to be precise) loaded from a plist, every point is an annotation on the map. I'd like to limit the view to the two nearest annotation points around the user's current location. 回答1: Roughly, the steps would be: Find current location, convert to MKMapPoint Iterate your list of annotations, using MKMetersBetweenMapPoints to find distance from current

Custom curent location Annotation pin not updating with core location

丶灬走出姿态 提交于 2019-12-08 08:41:29
问题 Trying to add a custom pin for current location, However the location does not update. Even after setting setShowsUserLocation = YES; - (id)initWithAnnotation:(id <MKAnnotation>)annotation reuseIdentifier:(NSString *)reuseIdentifier { self = [super initWithAnnotation:annotation reuseIdentifier:reuseIdentifier]; if ([[annotation title] isEqualToString:@"Current Location"]) { self.image = [UIImage imageNamed:[NSString stringWithFormat:@"cursor_%i.png", [[Session instance].current_option

Draw polyline in mapview iOS 6

﹥>﹥吖頭↗ 提交于 2019-12-08 05:45:37
问题 Hi I'm doing an app that must to show a map with the route. I parsed a Json to obtain the points to draw the polyline. I found a a code in the web to draw this polyline. The code I found it's on this link: http://iosguy.com/2012/05/22/tracing-routes-with-mapkit/ Where it says "Create the MKPolyline annotation" I tried to import this in my app, but I'm having problems to create the array of the coordinates. My method is this: - (void)createMKpolylineAnnotation { NSInteger numberOfSteps = self

Setting image for MKAnnotation

点点圈 提交于 2019-12-08 02:56:23
问题 I added MKAnnotation in my mapview using the following code. Flag *flag = [[Flag alloc] init]; flag.title = @"Golf Course"; flag.subtitle = @"Green"; flag.coordinate =CLLocationCoordinate2DMake(28.457394,77.108667); [mapView addAnnotation:flag]; and am setting image like -(MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation: (id <MKAnnotation>)annotation { if(([annotation isKindOfClass:[Flag class]])) { MKPinAnnotationView *pinView = nil; if(annotation != mapView.userLocation) {

Draw MKPointAnnotation with title in MKSnapshot image

空扰寡人 提交于 2019-12-08 01:04:31
问题 I'm trying to draw an annotation exactly as in a 'live' MapView, but then in a MKSnapshot. Why an MKSnapshot > because I want to have non-interactive MapViews in a UITableView and using images is more efficient. I can get a pin to be drawn (though not a point as in iOS 11, the pin looks old) using MKPinAnnotationView, but also then there is no title of the annotation on the image. Using almost exactly this code: Snapshot of MKMapView in iOS7. 回答1: You can use the following steps: with

How to delete the last annotation on a mapView

假装没事ソ 提交于 2019-12-07 12:59:31
I have added a button on my .xib file with which I want to delete the last annotation that has been added. So on the Touch-Down action I have implemented this: -(IBAction)DeleteAnnotation:(id)sender { [mapview removeAnnotation:[mapview.annotations lastObject]]; } and I have even tried it this way: -(IBAction)DeleteAnnotation:(id)sender { [self.mapview removeAnnotation:self.mapview.annotations.lastObject]]; } where mapview is my MKMapView Outlet. The problem I encounter with both ways is that I have to press this specific button quite a few times before an annotation is removed. Furthermore,

How to make custom MKAnnotation draggable

狂风中的少年 提交于 2019-12-07 07:14:49
问题 I need MKAnnotation with different pin image. So I created following: @interface NavigationAnnotation : NSObject <MKAnnotation> - (id)initWithName:(NSString*)name address:(NSString*)address coordinate:(CLLocationCoordinate2D)coordinate; ... @interface NavigationAnnotation () @property (nonatomic, copy) NSString *name; @property (nonatomic, copy) NSString *address; @property (nonatomic, assign) CLLocationCoordinate2D theCoordinate; @end @implementation NavigationAnnotation - (id)initWithName:

custom MKAnnotation not moving when coordinate set

空扰寡人 提交于 2019-12-07 01:34:05
问题 I've got a custom MKAnnotation set up class Location: NSObject, MKAnnotation { var id: Int var title: String? var name: String var coordinate: CLLocationCoordinate2D { didSet{ didChangeValueForKey("coordinate") } } when i set the coordinate it does not move the pin on the map. I added the 'didSet' with the key word coordinate as i found people saying that would force it to update. but nothing, it doesn't move. i have verified the lat / long have changed and are correct, the pin just isn't