mkannotation

How to access to an annotation attribute inside method calloutAccessoryControlTapped

穿精又带淫゛_ 提交于 2019-11-29 12:46:40
I am trying to open a detail viewController when a user taps on the callout from a map annotation. I have created a custom annotation subclass called myAnnotation, and there I have included a property called idEmpresa. At a custom method I am declaring the annotation as follows: double latitud = [[[categorias objectAtIndex:i] objectForKey:@"latitud"] doubleValue]; double longitud = [[[categorias objectAtIndex:i] objectForKey:@"longitud"]doubleValue]; CLLocationCoordinate2D lugar; lugar.latitude = latitud; lugar.longitude = longitud; NSString *nombre = [[categorias objectAtIndex:i] objectForKey

Need to add a Fixed Overlay like on mapview in IOS

耗尽温柔 提交于 2019-11-29 12:35:45
I need to create a map view interface, which is something similar to the OLA Cabs Application in iOS. What I exactly wanna do is to fix an overlay on mapView and allow the user to scroll the map view across it. So that the overlay can be fixed at any location the User wants it to, I searched a lot about overlays, in iOS and MapKit, but couldn't make it possible. If some one can give me tips for achieving this I would be really grateful. Here is a snapshot of the screen Here the annotation remains fixed and you can move the map view across it, So that when you stop the mapview, the overlay will

Adding a route to a MKMapView

点点圈 提交于 2019-11-29 08:01:11
I'm trying to add a routing feature to an app I'm working on. I found Craig Spitzkoff's article on how to draw lines on an MKMapView which works pretty good. But since I don't have the coordinates of the points on the roads that doesn't help me as expected. Is there any way to determine the coordinates between to given points, say my current position and another address? Basically you will need to make an HTTP request to the Google Directions API . The terms of service state that you have to display the results on a Google map, but I think because you are using an MKMapView, you will be fine:

moving/updating MKOverlay on MKMapView

牧云@^-^@ 提交于 2019-11-29 03:14:17
问题 is there a way to update (i.e. moving around) a MKOverlay that is already added to the MKMapView . Removing a old one and adding a new one is terrible (slow). i.e i would like to trigger the background function that is calling this function when an overlay moves on the screen: - (MKOverlayView *)mapView:(MKMapView *)mapView viewForOverlay:(id <MKOverlay>)overlay (with MKAnnotions its a little better i think, but i cant use MKPolyline , MKPolygon , etc. and the whole information is reduced to

Is it possible to call animatesDrop in a MKAnnotationView rather than MKPinAnnotationView?

与世无争的帅哥 提交于 2019-11-29 02:04:21
do you know that MKPinAnnotationView has a method "animatesDrop" to animate a pin annotation from the top to point on the map with a shadow? OK, is it possible do this with a custom image?? gcamp You can always do your custom animation in MKMapViewDelegate method. - (void)mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views Probably something like that (you won't get the fancy shadow animation, if you want it you need to do it yourself) : - (void) mapView:(MKMapView *)mapView didAddAnnotationViews:(NSArray *)views { CGRect visibleRect = [mapView annotationVisibleRect]; for

How do I remove all annotations from MKMapView except the user location annotation?

廉价感情. 提交于 2019-11-28 19:39:53
问题 I use removeAnnotations to remove my annotations from mapView but same it remove user location ann. How can I prevent this, or how to get user ann back to view? NSArray *annotationsOnMap = mapView.annotations; [mapView removeAnnotations:annotationsOnMap]; 回答1: Update: When I tried with the iOS 9 SDK the user annotation is no longer removed. You can simply use mapView.removeAnnotations(mapView.annotations) Historical answer (for apps that run on iOS before iOS 9): Try this: NSMutableArray *

MapKit (MKMapView): zPosition does not work anymore on iOS11

不问归期 提交于 2019-11-28 18:50:05
On iOS11 the zPosition stopped working for the annotationView.layer. Every time the map region changes. No luck with original solution: layer.zPosition = X; No luck with bringViewToFront / SendViewToBack methods Xcode 8.3/9 UPDATE (SOLUTION thanks Elias Aalto): When creating MKAnnotationView: annotationView.layer.zPosition = 50; if (IS_OS_11_OR_LATER) { annotationView.layer.name = @"50"; [annotationView.layer addObserver:MeLikeSingleton forKeyPath:@"zPosition" options:0 context:NULL]; } In MeLikeSingleton or whatever observer object you have there: - (void)observeValueForKeyPath:(NSString *

Drag an annotation pin on a mapview

心不动则不痛 提交于 2019-11-28 17:39:05
The annotation pin is draggable but I couldn't drop it to the destination location. The problem is how could I get the destination location's coordinate where i drop the annotation pin? Any method exist? Edit 1: The center of the annotation pin seems never changed where ever I drop the pin. - (void)mapView:(MKMapView *)mapView annotationView:(MKAnnotationView *)annotationView didChangeDragState:(MKAnnotationViewDragState)newState fromOldState:(MKAnnotationViewDragState)oldState { if (newState == MKAnnotationViewDragStateEnding) { NSLog(@"x is %f", annotationView.center.x); NSLog(@"y is %f",

MKAnnotation not getting selected in iOS5

落爺英雄遲暮 提交于 2019-11-28 13:45:15
My app places a pushpin on the map and then selects its using animation so the user has a visual clue and can immediately read the title/subtitle. The following code works in both iOS4 and iOS5, but in iOS5, the annotation doesn't get selected automatically unless I change the animation to NO in the selectAnnotation method. Any ideas why? MapAnnotations *pushpin = [[MapAnnotations alloc] initWithCoordinate:coordinate]; pushpin.title = [selectedStation valueForKey:@"name"]; pushpin.subtitle = [selectedStation valueForKey:@"address"]; [stationMap addAnnotation:pushpin]; [stationMap

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