mapkit

MapKit iOS 9 detailCalloutAccessoryView usage

徘徊边缘 提交于 2019-12-17 15:44:07
问题 After watching WWDC video 206 I assumed this would be a trivial task of adding the detail callout view to a mapView annotation view. So, I assume Im doing something wrong. With my pin view set up func mapView(mapView: MKMapView, viewForAnnotation annotation: MKAnnotation) -> MKAnnotationView? { let view:MKAnnotationView! if let dequed = routeMapView.dequeueReusableAnnotationViewWithIdentifier("pin") { view = dequed } else { view = MKPinAnnotationView(annotation: annotation, reuseIdentifier:

Convert coordinates to City name?

不羁岁月 提交于 2019-12-17 15:21:49
问题 How to get an address from coordinates using MapKit? I have this code when long press on the map it gets the coordinates: func didLongPressMap(sender: UILongPressGestureRecognizer) { if sender.state == UIGestureRecognizerState.Began { let touchPoint = sender.locationInView(self.mapView) let touchCoordinate = self.mapView.convertPoint(touchPoint, toCoordinateFromView: self.mapView) var annotation = MKPointAnnotation() annotation.coordinate = touchCoordinate annotation.title = "Your position"

MKPolygon area calculation

霸气de小男生 提交于 2019-12-17 09:49:43
问题 I'm trying to make an area calculation category for MKPolygon. I found some JS code https://github.com/mapbox/geojson-area/blob/master/index.js#L1 with a link to the algorithm: http://trs-new.jpl.nasa.gov/dspace/handle/2014/40409. It says: Here is my code, which gave a wrong result (thousands times more than actual): #define kEarthRadius 6378137 @implementation MKPolygon (AreaCalculation) - (double) area { double area = 0; NSArray *coords = [self coordinates]; if (coords.count > 2) {

Centering MKMapView on spot N-pixels below pin

三世轮回 提交于 2019-12-17 07:17:21
问题 Want to center MKMapView on a point N-pixels below a given pin ( which may or may not be visible in the current MapRect ). I've been trying to solve this using various plays with -(CLLocationCoordinate2D)convertPoint:(CGPoint)point toCoordinateFromView:(UIView *)view to no success. Anyone been down this road ( no pun intended )? 回答1: The easiest technique is to just shift the map down, say 40% from where the coordinate would be, taking advantage of the span of the region of the MKMapView . If

How to add a button to the MKPointAnnotation?

有些话、适合烂在心里 提交于 2019-12-17 06:49:09
问题 I've just got stuck trying to add a detail button to my annotation point, unfortunately I don't know how to do it. Does anyone could help me with that? The image below presents what I'd like to achieve. Thanks! MapKitViewController: import UIKit import MapKit import CoreLocation class MapKitViewController: UIViewController, MKMapViewDelegate { let locationManager = CLLocationManager() @IBOutlet weak var nmapView: MKMapView! override func viewDidLoad() { super.viewDidLoad() locationManager

Animated gif not working in MKMapView overlay using MKOverlayRenderer

≡放荡痞女 提交于 2019-12-17 06:45:31
问题 I am trying to display an animated gif in an overlay for MKMapView . The overlay is created using the MKOverlayRenderer . To animate the gif in iOS 7, I'm using the UIImage+animatedGIF category posted here on GitHub. The image of the animated gif displays fine in the overlay using the category; however, the gif does not animate. I have no problem using the category to animate a gif in a UIImageView but it does not seem to work correctly in a map view overlay. How can I use this category to

Customize MKAnnotation Callout View?

混江龙づ霸主 提交于 2019-12-17 04:48:27
问题 I have a MKPointAnnotation : let ann = MKPointAnnotation() self.ann.coordinate = annLoc self.ann.title = "Customize me" self.ann.subtitle = "???" self.mapView.addAnnotation(ann) It looks like this: How can I customize this callout view to create my own view instead of the predefined one? 回答1: It should first be noted that the simplest changes to the callout are enabled by simply adjusting the properties of the system provided callout, but customizing the right and left accessories (via

How to create rounded image with border and shadow as MKAnnotationView in Swift?

 ̄綄美尐妖づ 提交于 2019-12-14 03:54:00
问题 I'd like to create MKAnnotationView that looks like the one below. The code I already have: func maskRoundedImage(image: UIImage, radius: Float) -> UIImage { let imageView: UIImageView = UIImageView(image: image) var layer: CALayer = CALayer() layer = imageView.layer layer.masksToBounds = true layer.cornerRadius = CGFloat(radius) layer.borderWidth = 4.0 layer.borderColor = UIColor.whiteColor().CGColor UIGraphicsBeginImageContext(imageView.bounds.size) layer.renderInContext

CalloutAccessoryView view for MKPinAnnotationView

…衆ロ難τιáo~ 提交于 2019-12-14 03:22:28
问题 We have rightCalloutAccessoryView and leftCalloutAccessoryView for MKPinAnnotationView but is there if we need to add a custom button to the entire popup bubble how to add it the main requirement is i need to perform same action when we tap on Popup bubble just like disclser Button action. //To add a discloser button to show route map inView = (MKPinAnnotationView *)[mapView dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; UIButton *detailBtn=[UIButton buttonWithType

Cannot get UIMapView to “zoom”/setRegion: when the map is loaded for the first time

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-14 01:03:37
问题 I have a UIViewController that loads a map with a bunch of pins already on it. There's no issues getting the pins to appear, but I can't seem to get MKMapView to execute setRegion when the user first reaches the mapView. I've tried putting the code in every possible method that could work, viewDidLoad , viewWillLoad , mapViewWillStartLoadingMap , mapViewDidFinishLoadingMap , etc., to no avail. And yet, it WILL "zoom" to the designated region if I return to the previous viewController and then