mapkit

Storing CLLocation and keeping annotation

天涯浪子 提交于 2019-12-13 05:03:44
问题 My app currently has three tabs, a tab for pinning a location, and a detailView of the pinned location on the second tab. I am trying to save the location of the pin into NSUserdefaults. I would then like that location to stay pinned upon reloading the app, and therefore the detail view would still display the detail view of the pinned location. Here is what I have so far, func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!) { // Find location of user

How to put iOS Magnifying Glass effect on Google Maps (GMSMapKit)

感情迁移 提交于 2019-12-13 05:03:03
问题 How to put the UITextView texting editing Magnifying Glass on the Google Maps GMSMapView For example I have a GMSMapView to show my current location I want to trigger a overlay Magnifying Glass view when calling delegate methods mapView:didChangeCameraPosition: and mapView:willMove: in GMSMapViewDelegate The purpose is to provide an overlay zooming subView according to the user tapping coordinates (like github.com/acoomans/iOS-MagnifyingGlass did on ImageView) Please let me know if this is

How to prevent overlays on the map from disappearing when zoom scale changes in swift?

随声附和 提交于 2019-12-13 04:18:55
问题 I am trying to render an overlay (polygon) on the map using swift MapKit. I can render successfully but when I zoom out too much then zoom in again, all the rendered polygons get disappear. How can I prevent that from happening and force the rendered polygons to stay on the map at all zoom scales? I am using MapKit and MKPolygonRenderer. I add the polygons to the map using the following method in my viewController: // function to add polygon overlay to the map private func addPolygonsToMap()

iPhone Development - Is Pin Annotation in a viewable Map Region

大兔子大兔子 提交于 2019-12-13 03:05:04
问题 How can i check if a pin is in viewable region of the map (MKMapView)? 回答1: A pin is a MKPinAnnotationView , it extends from MKAnnotationView and has a property annotation (that conforms to the protocol MKAnnotation ). Such annotation has itself another property coordinate . Just compare the latitude / longitude of such coordinate to the region of your map. something like this should do it : double minLong = myMap.region.center.longitude - myMap.region.span.longitudeDelta/2.0; double maxLong

How to zoom into user current location?

喜夏-厌秋 提交于 2019-12-13 02:55:25
问题 I wanna zoom into the user current location when the app starts in the MapKit. This is my code (in the viewDidLoad function): Locate=[[CLLocationManager alloc]init]; Locate.delegate=self; Locate.desiredAccuracy=kCLLocationAccuracyBestForNavigation; Locate.distanceFilter=kCLDistanceFilterNone; [Locate startUpdatingLocation]; [super viewDidLoad]; //Region MKCoordinateRegion myRegion; //Center CLLocationCoordinate2D center; center.latitude=Locate.location.coordinate.latitude; center.longitude

MKPolyline only shown when map is moved

末鹿安然 提交于 2019-12-13 02:45:16
问题 I have a MKMapView with some pins on it. I connect the pins with a MKPolyline view. But the MKPolyline is only shown when I move the map (when the MapView is updated?). I want to see the MKPolyline from the beginning on. Please inspect the following code: -(void)plotSnapPosition { for (id<MKAnnotation> annotation in myMapView.annotations) { [myMapView removeAnnotation:annotation]; } for (id<MKOverlay> overlay in myMapView.overlays) { [myMapView removeOverlay:overlay]; } NSArray *snaps = self

Subclassing MKAnnotationView with use of auto layout

这一生的挚爱 提交于 2019-12-13 01:30:06
问题 I like the new auto layout functionality in iOS 6 but I've run into a bit of trouble when using it in combination with my MKAnnotationView subclass. I've disabled the autoresizing mask translation in the initialization method. self.translatesAutoresizingMaskIntoConstraints = NO; But the app throws an NSInternalInconsistencyException when I load the MKMapView that uses an annotation of my subclass. *** Assertion failure in -[ENMapAnnotationView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim

How do I extend a NSManagedObject to contain MKAnnotation in Swift?

爱⌒轻易说出口 提交于 2019-12-13 00:40:47
问题 I have a Photo class class Photo: NSManagedObject { } I want to extend it to provide MKAnnotation I tried doing it so by extension Photo: MKAnnotation { var coordinate: CLLocationCoordinate2D However the compiler complains that extensions cannot have stored properties. Is there a better way of accomplishing this? Thanks. 回答1: You cannot have stored properties, but you can have calculated properties! I.e: var coordinate : CLLocationCoordinate2D { get { return CLLocationCoordinate2D(latitude:

Returning Mapkit Userlocation Coordinates

 ̄綄美尐妖づ 提交于 2019-12-13 00:27:14
问题 whenever I try to return the lat/long coordinates for my current location, my application crashes with no explanation of the error... NSLog(@"%@", mapView.userLocation.location.coordinate); I am waiting until the phone finds the location as well... 回答1: mapView.userLocation.location.coordinate is a struct while the %@ format specifier expects an object. This will work: NSLog(@"%f, %f", mapView.userLocation.location.coordinate.latitude, mapView.userLocation.location.coordinate.longitude); 回答2:

Custom MKAnnotationView touch zone is ridiculously narrow

安稳与你 提交于 2019-12-13 00:23:38
问题 My custom MKAnnotationView subclass do not set it's image property. Instead, it handle some subviews to be displayed. I implement public func mapView(_ mapView: MKMapView, didSelect view: MKAnnotationView) in my delegate to detect annotation touch. Because touch zone is by default calculated with the image property, my annotation view touch zone is about 1px large. This is ridiculous. This is how I create it: init(annotation: JZStreamAnnotation) { self.imageView = UIImageView.init(image: <an