mapkit

CLLocation returning negative speed

北城以北 提交于 2019-11-29 09:28:56
I'm starting a new app which uses the coreLocation and the mapkit frameworks. My problem is trying to get the current speed always returns me a negative value, i have take my iPhone with me to places with a good 3g signal and it doesn't matter, location.speed value is always -1. here is the code which matters: #define kRequiredAccuracy 1500.0 //meters #define kMaxAge 60.0 //seconds in the init method: self.locationManager=[[CLLocationManager alloc] init]; self.locationManager.delegate=self; self.locationManager.desiredAccuracy=kCLLocationAccuracyNearestTenMeters; then didUpdateToLocation: -

Rendering MKMapView to UIImage with real resolution

ⅰ亾dé卋堺 提交于 2019-11-29 09:21:56
问题 I am using this function for rendering MKMapView instance into image: @implementation UIView (Ext) - (UIImage*) renderToImage { UIGraphicsBeginImageContext(self.frame.size); [self.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return image; } This works fine. But with iphone4 the rendered image doesn't have same resolution as it has really on device. On device I have the 640x920 map view quality,

Is it possible to inherit from MKPolyline

久未见 提交于 2019-11-29 09:02:43
问题 I'm building a MapKit based app for iPhone. I have a number of MKPolylines added to the map. However, instead of having a MKPolyline, I would like to have my own Model class conforming to the MKOverlay protocol added to the map so that I can access the model properties when creating the corresponding view in mapView:viewForOverlay. The problem is that I can't find the way to inherit from MKPolyline because it doesn't have any init methods that I can call from the subclass' init. You can only

Draw polyline using Swift

非 Y 不嫁゛ 提交于 2019-11-29 08:48:58
问题 I'm trying to get an understanding of how to draw polylines using Swift. I've looked at the documentation, referenced some tutorials, and checked out some other SO posts, but I still can't get the thing to draw a line on my map. Here's my code. Anyone tell me what I'm doing wrong here? import UIKit import MapKit class FirstViewController: UIViewController { @IBOutlet weak var map: MKMapView! override func viewDidAppear(animated: Bool) { super.viewDidAppear(animated) let location =

(iPhone) how to implement draggable pins using OS 4.0 MapKit?

北战南征 提交于 2019-11-29 08:21:35
问题 Can anyone provide any sample code/instructions for implementing draggable pins in OS 4.0 using the MapKit framework? 回答1: Sure thing buddy (yes I'm talking to myself), In your custom annotation add: @property (nonatomic, readwrite, assign) CLLocationCoordinate2D coordinate; This satisfies the requirement of implementing setCoordinate, as mentioned inhttp://developer.apple.com/iphone/library/documentation/MapKit/Reference/MKAnnotationView_Class/Reference/Reference.html#//apple_ref/occ/instp

iOS Custom Annotation: A view below the annotation pin

江枫思渺然 提交于 2019-11-29 08:03:18
I need to replace the default annotation view with my custom annotation view. I need the do following things: Custom Annotation view with an image view embedded in it. A view below it which contains a label in it. For more clarification see the image: In the above image I need to place an image view in the white space which you can see in the image in circular form, next I also need to add a view which contains a label on which I can set any text like me, friends, etc... So, for this I searched number of questions on stack overflow but didn't got my answer. I don't want it on call out, I just

How to handle taps on a custom callout view?

非 Y 不嫁゛ 提交于 2019-11-29 07:55:44
I am adding a callout view like this: func mapView(mapView: MKMapView!, didSelectAnnotationView view: MKAnnotationView!) { let calloutView = UIView(frame: CGRect(x: 0, y: 0, width: 300, height: 120)) calloutView.backgroundColor = UIColor.purpleColor() calloutView.center = CGPointMake(CGRectGetWidth(view.bounds) / 2.0, 0.0) calloutView.layer.anchorPoint = CGPointMake(0.5, 1.0) calloutView.layer.masksToBounds = false calloutView.userInteractionEnabled = true let calloutViewTapRecognizer = UITapGestureRecognizer(target: self, action: "onCalloutViewTap") calloutView.addGestureRecognizer

Why does a custom MKMapView annotation image disappear on touch?

夙愿已清 提交于 2019-11-29 07:18:24
I am annotating my map and setting an image just fine, but when I tap the annotation on the MapView, the image goes from my custom image back to the red pin. Why is this? - (MKAnnotationView *)mapView:(MKMapView *)newMapView viewForAnnotation:(id )newAnnotation { MKPinAnnotationView *annotation = [[MKPinAnnotationView alloc] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"]; if (annotation == nil) { annotation = [[MKAnnotationView alloc] initWithAnnotation:newAnnotation reuseIdentifier:@"currentloc"]; } annotation.image = [UIImage imageNamed:@"anno.png"]; annotation

How to determine the correct altitude for an MKMapCamera focusing on an MKPolygon

◇◆丶佛笑我妖孽 提交于 2019-11-29 07:17:49
I need to figure out how to set up MKMapSnapshotterOptions to take a snapshot of aerial/satellite imagery associated with a polygonal region of the earth. Filling out the 'region', 'scale', 'size', and 'mapType' properties are trivial, as I have an MKPolygon to work with. The tricky part is in setting the 'camera' -- in my particular case, I am using MKMapSnapshotter independently of the MKMapView (in fact, not even on the main thread). However, I would prefer to orient the snapshot so that it fits the bounds of the polygon based on a non-zero heading -- that is, the area that I am taking a

How can I clear MKMapView's cache of map tiles?

℡╲_俬逩灬. 提交于 2019-11-29 06:59:58
I am working on an MKMapView based iPhone / iPad mapping app that overlays my own basic base map to provide for some limited functionality even when users are offline and can not reach Google's map tile server. This functionality is working - but I am having a hard time testing it after each new build because I can't find a way to flush / reset the iOS map tile cache. The iOS cache even survives a power-cycle and reboot of the iOS device. Anywhere I have zoomed into in the past renders with the tiles in memory from the prior test session. Is there a way to force iOS to flush its map cache?