mapkit

Get info on a mapview selected annotation

青春壹個敷衍的年華 提交于 2019-12-20 03:22:17
问题 I have annotations on a mapview and a callout with a button on each. What I need to do is grab properties from this callout, ie. the title, but logging this line: NSLog(@"%@", mapView.selectedAnnotations); returns <AddressAnnotation: 0x1bdc60> which obviously gives me no useful info... My question is, how can I access the properties of a selected annotation callout? 回答1: This is how for (id annotation in mapView.annotations) {NSLog([annotation title]);} 回答2: Here is what I did in the

Convert distance on MKMapView to distance for UIView

大兔子大兔子 提交于 2019-12-20 02:59:15
问题 How do I convert distance (for example 400 meters) on MKMapView to distance for UIView? I want to show MKAnnotationView that depends on current zoom level on MKMapView. 回答1: First, create a region with 400 meters length: MKCoordinateRegion myRegion = MKCoordinateRegionMakeWithDistance(mapView.centerCoordinate, 400, 0); After that use convert region methods for getting real rect: CGRect myRect = [mapView convertRegion: myRegion toRectToView: nil]; NSLog(@"width for 400m is %f", myRect.size

Why is the MKMapView's userLocation property rubbish … for a while?

陌路散爱 提交于 2019-12-20 02:38:07
问题 I have a Map View defined in IB and it is set to show the user location. In my app, in -viewDidAppear , I query self.mapView.userLocation.location.coordinate and it comes back with insane values such as: latitude : 4.8194501961644877e-49 longitude : 2.2993313035571993e-59 However, the next time -viewDidAppear is called (after I've simply moved to another tabbed view and then back to this one) the userLocation property holds exactly the correct values for my current location. It seems that at

MKMapView constantly monitor heading

♀尐吖头ヾ 提交于 2019-12-19 11:37:11
问题 I'm rendering some content in a layer that sits on top of my MKMapView . The whole thing works great with the exception of rotation. When a user rotates the map I need to be able to rotate what I'm rendering in my own layer. The standard answer I found is to use: NSLog(@"heading: %f", self.mapView.camera.heading"); The issue with this is that the content of the heading variable only updates when the pinch/rotate gesture is ending, not during the gesture. I need much more frequent updates.

Hiding mapview when mapoverlay is visible ios7

烂漫一生 提交于 2019-12-19 11:27:03
问题 How do I hide the mapview when I have an overlay on top of the mapview in iOS7? This snippet of code used to work in iOS6 but when i upgrade my app to iOS7 it cease to work. NSArray *views = [[[self.mapView subviews] objectAtIndex:0] subviews]; [[views objectAtIndex:0] setHidden:YES]; Any suggestions or feedback? 回答1: With what incanus said with MKTileOverlay , it is like this in the view controller: - (void)viewDidLoad { [super viewDidLoad]; NSString *tileTemplate = @"http://tile.stamen.com

Custom Annotation View do not work on iOS6

被刻印的时光 ゝ 提交于 2019-12-19 10:18:53
问题 I'm using the J4n0 Callout code (github) to implement a custom annotation in MapKit. It was working just fine on iOS5. But on iOS6 I have 2 problems: Annotations are displayed over the AnnotationView (see picture 1). The first Click on an Annotation opens the AnnotationView just fine, but the second click opens an annotation with a bad size (see picture 2). Does anyone using this library have some similar problem/solution? I can give some code if needed! 回答1: If annotations are displayed over

MapView Annotation not dragging

て烟熏妆下的殇ゞ 提交于 2019-12-19 08:26:22
问题 I am trying to implement a draggable "pin" (actually a custom icon) in a map view. This is the delegate code that I have: -(MKAnnotationView *) mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation { MKAnnotationView *aView; aView=(MKAnnotationView *) [mvMap dequeueReusableAnnotationViewWithIdentifier:annotation.title]; if (aView==nil) aView=[[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier:annotation.title] autorelease]; else aView.annotation

How do I show MKOverlay above MKAnnotations?

元气小坏坏 提交于 2019-12-19 06:18:08
问题 I'm trying to use an MKOverlay (specifically an MKPolyline ) to show a route on the map. However, I need the route to show up above my existing pins (custom MKAnnotationView s). Is there a good way to bring the MKPolyline to the front above the pins? 回答1: It might be useful to investigate the annotation layer's zOrder property. Sending the annotations backwards in your superview's hierarchy may help you achieve the effect needed. Changing your annotation z-axis position should probably be

To draw polygon on google map with MapKit framework

廉价感情. 提交于 2019-12-19 03:45:12
问题 I wanted to display Google map in a map view on which I want to draw a polygon/circle. Any advice? 回答1: The way I'm reading your question is that you want to programmatically draw the polygon on the map. For this, consult the Apple docs on MapKit. You don't need to add transparent views over the MapKit map ( MKMapView ). You create an overlay object, in this case an MKPolygon . (in the following example, the variable map will be the MKMapView instance owned by the view controller that you put

iPhone Mapkit adding custom image and pins to annotations

倖福魔咒の 提交于 2019-12-18 18:04:34
问题 I am trying to change the pin colour from the default red to a custom image but whatever I am trying just isn't working. I have downloaded the sample code from this website: http://icodeblog.com/2009/12/21/introduction-to-mapkit-in-iphone-os-3-0/ The code works on it's own but when I import the annotation classes into my code, they do not work and I have no idea why. I have also tried a number of different methods from other sites but I can't even get the pin colour to change. My project has