mkmapviewdelegate

How can I center my mapview so that the selected pin is not in the middle of the map but in 1/3 of it?

喜欢而已 提交于 2019-12-12 00:02:50
问题 I have coordinates of a single pin on my map. I try to center my map on that pin, but I don't want to keep the pin directly in the middle of the map, but in 1/3 of the screen. I tried to do it in the following workaround: let coordinateRegion = MKCoordinateRegionMakeWithDistance(coordinatesOfThePin, 500, 500) mapView.setRegion(coordinateRegion, animated: true) let frame = mapView.frame let myPoint = CGPointMake(frame.midX, frame.midY/3) let myCoordinate = mapView.convertPoint(myPoint,

My annotations doesn't show the Sub Title in the PIN

…衆ロ難τιáo~ 提交于 2019-12-11 07:14:26
问题 in the implementations class charged of displaying PINS, i have reserved two variables (title and sub title), in this example, only the word USA (the title) is displayed when i click on the PIN. CLLocationCoordinate2D location2D = (CLLocationCoordinate2D){ .latitude = latitudeOfUserLocation, .longitude = longitudeOfUserLocation }; ManageAnnotations *annotation=[[ManageAnnotations alloc]initWithTitle:@"USA" adresseDuTheme:@"Colorado" coordinate:location2D];//only USA is displayed annotation

Center MKMapView BEFORE displaying callout

人盡茶涼 提交于 2019-12-10 18:48:57
问题 I am trying to center an MKMapView after an annotation was selected. I also have enabled canShowCallout but it seems that iOS is first displaying the callout (which is shifted when it would not fit in the screen) and then the map is being moved, resulting in the callout being not completely visible on the screen. How can I center the map BEFORE the callout's position is being rendered and displayed? 回答1: I wanted to accomplish the same thing and ended up doing the following. A word of caution

How to suppress the “Current Location” callout in map view

谁说我不能喝 提交于 2019-12-09 08:25:47
问题 Tapping the pulsating blue circle representing the userLocation brings up a "Current Location" callout. Is there a way to suppress that? 回答1: There's a property on the annotation view you can change, once the user location has been updated: - (void)mapView:(MKMapView *)mapView didUpdateUserLocation:(MKUserLocation *)userLocation { MKAnnotationView *userLocationView = [mapView viewForAnnotation:userLocation]; userLocationView.canShowCallout = NO; } 回答2: You can set the title to blank to

How to update information on MKPinAnnotationView?

坚强是说给别人听的谎言 提交于 2019-12-09 06:49:25
I've had some past experience using MKMapView and MKPointAnnotation , which I used to put some pin on a map. This time I am trying to go one step further and use MKPinAnnotationView , to write a label along with some of the pins. Unfortunately, it doesn't all work as I expect. Here is what I want to do: I have a map (an MKMapView object) and when I touch it, I put a pin at the touch point, then some computation is performed and this gives me a second point on the map. I put a second pin on the map (located at the second point), on this last pin I want to put a label, say "Hello Second!", but

MKMapView crashes app when view controller popped

混江龙づ霸主 提交于 2019-12-07 03:05:51
问题 I have a view controller with an MKMapView that calls [self.mapView setRegion:region animated:YES]; which repositions the map from A to B. The view controller which holds the MKMapView is set as the delegate and in - (void)mapView:(MKMapView *)mapView regionDidChangeAnimated:(BOOL)animated I have some code that will trigger another setRegion:animated: to the MKMapView so that the map will zoom in on the new position automatically. Everything works fine if I popViewControllerAnimated: the view

Can you create an annotation in Mapview from an address?

坚强是说给别人听的谎言 提交于 2019-12-05 08:12:22
问题 I have "googled" this question a few times today with no luck. I would like to know if it is possible to create an annotation in Mapview from an address rather than using the lat/Long method. My current code is below. //1. Create a coordinate for use with the annotation CLLocationCoordinate2D Sharon; Sharon.latitude = 38.952223; Sharon.longitude = -77.193646; Annotation *myAnnotation = [Annotation alloc]; myAnnotation.coordinate = Sharon; myAnnotation.title = @"Sharon Lodge #327";

Custom font for MKAnnotationView Callout

心已入冬 提交于 2019-12-04 04:55:00
问题 Fortunately, the standard callout view for an MKAnnotationView meets our needs - title , subtitle , leftCalloutAccessoryView , and rightCalloutAccessoryView . Unfortunately, we use custom fonts in our app, and would like to extend those custom fonts to these callouts. MKAnnotationView provides no standard way to accomplish this. How can I use a custom font in an MKAnnotation 's callout view? 回答1: Since I needed the Swift version - here it is. Also, you have to call setNeedsLayout() on

Detecting when MapView tiles are displayed

倾然丶 夕夏残阳落幕 提交于 2019-12-04 01:15:39
问题 Since - (void)mapViewDidFinishLoadingMap:(MKMapView *)mapView is not called when the tiles are loaded from cache, is there a way to know when all the tiles have been loaded (either from cache or from the mapping servers) and displayed? Is there any delegation that intimates that tiles have been loaded ? 回答1: Here is some source code I wrote: https://github.com/jonathanlking/mapViewTest Why don't you think about the problem like this; When the map view will change, mapView

Can you create an annotation in Mapview from an address?

你。 提交于 2019-12-03 23:12:55
I have "googled" this question a few times today with no luck. I would like to know if it is possible to create an annotation in Mapview from an address rather than using the lat/Long method. My current code is below. //1. Create a coordinate for use with the annotation CLLocationCoordinate2D Sharon; Sharon.latitude = 38.952223; Sharon.longitude = -77.193646; Annotation *myAnnotation = [Annotation alloc]; myAnnotation.coordinate = Sharon; myAnnotation.title = @"Sharon Lodge #327"; myAnnotation.subtitle = @"McLean, VA"; Try like this, NSString *location = "some address, state, and zip";