mkmapview

Setting MKMapView Zoom level to a locality

為{幸葍}努か 提交于 2020-01-04 03:45:22
问题 I wish to set the zoom level (OR set region) of MKMapView such that I can show a locality. Elaborating my context with an example. I have a location (CLLocation *) of which I found out the locality using CLGeocoder (reverse geocoding). Now, say the locality is 'Cupertino, CA' area. How do I find the region that completely encloses Cupertino in MKMapView? Thank you. 回答1: Create MKCoordinateRegion object and set map view region for that: CLLocationCoordinate2D location =

iOS set MKMapView center so supplied location is in the bottom center

£可爱£侵袭症+ 提交于 2020-01-03 16:59:16
问题 I have a MKMapView and a never changing CLLocationCoordinate2D. What I am trying to do is center the map so that this coordinate will be placed at the bottom center of the map. I am able to center the map on this coordinate with the simple: MKCoordinateRegion viewRegion = MKCoordinateRegionMakeWithDistance(mapCenter, 10000, 10000); [self.mapView setRegion:viewRegion animated:YES]; But how can I make it so that the map centers on the point that would make this mapCenter coordinate be placed at

is there any way of allowing zooming MKMapView only to a specific region, while disabling any other user interaction?

十年热恋 提交于 2020-01-03 16:00:13
问题 I have a swift app with a MapView. These are my settings on story board for the map: Also, in the code I'm doing: let regionRadius: CLLocationDistance = 10000 let initialLocation = CLLocation(latitude: latitude, longitude: longitude) centerMapOnLocation(initialLocation, map: cell.mapView, radius: regionRadius) cell.mapView.scrollEnabled = false cell.mapView.rotateEnabled = false My method centerMapOnLocation centers the map initially on a specific location: func centerMapOnLocation(location:

How to set the rotation center of an MKAnnotationView

白昼怎懂夜的黑 提交于 2020-01-03 07:33:49
问题 I've got a problem with my MKAnnotationView s when MKUserTrackingModeFollowWithHeading is enabled on the MKMapView. I positioned my images using the centerOffset property of the MKAnnotationView. Specifying the coordinates of the pin's tip relative to the coordinate system at the center of the image is somewhat counter-intutive, but I came up with the following formula: annotationView.centerOffset = CGPointMake(imageWidth/2.0 - tipXCoordinate, imageHeight/2.0 - tipYCordinate); This works fine

Detect when a second annotation is selected in a MKMapView

不打扰是莪最后的温柔 提交于 2020-01-03 07:25:10
问题 When a use selects an annotation in a map, I show a bottom view with informations, such as the google maps app. I'm showing it in the map's delegate : - (void)mapView:(MKMapView *)mapView didSelectAnnotationView:(MKAnnotationView *)view When the user deselects it (by taping anywhere on the map), I hide my bottom view. This is done in the opposite delegate method : - (void)mapView:(MKMapView *)mapView didDeselectAnnotationView:(MKAnnotationView *)view It works well, I'm happy with it. However,

Rotate MKMapView in iPhone application

↘锁芯ラ 提交于 2020-01-03 04:59:07
问题 I do not want any code but want to get reference for MKMapView compass rotation as shown in http://vimeo.com/7970239. Can anyone tell me that is it possible or not? Please help me to solve this problem.. Thanks in advance... 回答1: It is certainly possible, here is the very line that makes it work: [self.map setTransform:CGAffineTransformMakeRotation(-1 * newHeading.magneticHeading * M_PI / 180)]; In order to receive the heading events, you need to create a CLLocationManager and do

Gestures to subviews & MKMapView in iOS - basic iOS

偶尔善良 提交于 2020-01-03 04:49:08
问题 I have a following setup: mainViewController OverlayView - UIView mapView - MKMapView My OverlayView is shown over mapView and responds to UIPanGestureRecognizer Now because OverlayView is above MapView, I can't get the pinch to zoom functionality of MapView to work.. What do I have to do to get mapView to react to pinch and OverLayView to react to Pan (as it does now)? The solution I have now is just implementing the pinch2zoom functionality in the mainViewController so that it scales

Proper way of using CLLocationManager (to start/stop updating user location)

Deadly 提交于 2020-01-03 04:14:18
问题 I have a UIView with an MKMapView , in a UIViewController, which appears only when user taps a button. The process is as follows: A CLLocationManager object is declared as private member in the header file. A UIView with an MKMapView is presented (initially the frame is outside bounds. Is moved to within view bounds on user's action, WITHIN THE SAME viewController ). It is initialized: locationManager = [[CLLocationManager alloc] init]; locationManager.distanceFilter = kCLDistanceFilterNone;

How to delete the last annotation on a mapView

萝らか妹 提交于 2020-01-03 03:41:09
问题 I have added a button on my .xib file with which I want to delete the last annotation that has been added. So on the Touch-Down action I have implemented this: -(IBAction)DeleteAnnotation:(id)sender { [mapview removeAnnotation:[mapview.annotations lastObject]]; } and I have even tried it this way: -(IBAction)DeleteAnnotation:(id)sender { [self.mapview removeAnnotation:self.mapview.annotations.lastObject]]; } where mapview is my MKMapView Outlet. The problem I encounter with both ways is that

Create a title for annotation from MKLocalSearch

北城以北 提交于 2020-01-03 03:28:04
问题 I have added an MKLocalSearch and the pins are displaying correctly. The only problem is that the pins titles have both the name and address, were I only want the name. How would I change this. Here is the code I am using - - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated { MKLocalSearchRequest *request = [[MKLocalSearchRequest alloc] init]; request.naturalLanguageQuery = @"School"; request.region = mapView.region; MKLocalSearch *localSearch = [[MKLocalSearch alloc]