mkannotationview

Change the image's origin of map annotation view?

房东的猫 提交于 2019-12-04 04:28:55
The regular annotation pin's origin is in the middle of the bottom so, the pin always point to the same place. But when I add my custom image, its origin is the center of the image, so every zoom in or out, the bottom of my image point to a different place. Here my pin is supposed to point to the center of paris BUT but when I zoom in, the bottom of my pin isn't pointing to the center of Paris. I'm trying with the CGRect.origin but didn't get anything useful. Here is my code: - (MKAnnotationView *)mapView:(MKMapView *)theMapView viewForAnnotation:(id <MKAnnotation>)annotation {

Dragging the map after dragging my MKAnnotationView does not move the MKAnnotationView with it

荒凉一梦 提交于 2019-12-04 03:14:42
MKPinAnnotationView does not allow you to use a custom image as 'pin' and enable dragging at the same time, because the image will change back to the default pin as soon as you start dragging. Therefore I use an MKAnnotationView instead of an MKPinAnnotationView. While using MKAnnotationView instead of MKPinAnnotationView does keep your custom image shown as your 'pin' it doesn't support the drag & drop animation that you get with the default pin. Anyway, my issue is that after I drag my custom MKAnnotationView to a new point on the map and then move the map itself the MKAnnotationView does

Swift, How to get information from a custom annotation on clicked

余生颓废 提交于 2019-12-04 01:51:09
问题 I've got the following custom annotation class: import UIKit import MapKit class LocationMapAnnotation: NSObject, MKAnnotation { var title: String? var coordinate: CLLocationCoordinate2D var location: Location init(title: String, coordinate: CLLocationCoordinate2D, location: Location) { self.title = title self.coordinate = coordinate self.location = location } } I am loading the annotations into a map view like this: for i in 0..<allLocations.count{ //Add an annotation let l: Location = self

Show address in annotation when pin is dropped on map

冷暖自知 提交于 2019-12-03 20:39:48
Currently I can drop pins around the map. Now I want the annotation title to display the address of where the pin is dropped. I've had a look at this but cant get mine to work: Set annotation's title as current address Code in my ViewController.m Updated. - (void)addPinToMap:(UIGestureRecognizer *)gestureRecognizer { if (gestureRecognizer.state != UIGestureRecognizerStateBegan) return; CGPoint touchPoint = [gestureRecognizer locationInView:self.map]; CLLocationCoordinate2D touchMapCoordinate = [self.map convertPoint:touchPoint toCoordinateFromView:self.map]; CLLocation *currentLocation = [

I have 30 annotations, and growing. Looking for a simpler way to code this?

馋奶兔 提交于 2019-12-03 17:45:47
I am coding multiple annotations into a project. Currently I have 30 annotations, and growing. I'm wondering if there is a simplier way of having to create a annotation.h and annotation.m classes for each single annotation. Currently in my map view controller, I create the annotation objects and place them in an array, which has been working well for me but as you could imagine, its a lot of code to manage once you have tons of annotations, not to mention tons of classes. So for example, one of the annotation classes looks like this: Annotation.h: //Annotation.h #import <Foundation/Foundation

MKAnnotationView with custom view and image view

拜拜、爱过 提交于 2019-12-03 16:34:47
In my Map application, instead of showing a pin, I want to show a colored background circle with image in it. The color of the background (which is shade of green in below image) circle is dynamic. It will look as in below image: I created TCircleView which draws the color in "drawRect" To show similar annotation, I created object of TCircleView and UIImageView and add them to MKAnnotationView object. Its looking good and visible as expected. But its not allowing to detect tap/touch to show the call out. I'm using the below code: - (MKAnnotationView *)mapView:(MKMapView *)mapView

MKMapView -> display a button for my location

不打扰是莪最后的温柔 提交于 2019-12-03 15:34:05
I have a MKMapView implemented with these lines of source code (my location is a blue bullet, the other one's are purple pins): - (MKAnnotationView *)mapView:(MKMapView *)mapViewLocal viewForAnnotation:(id <MKAnnotation>)annotation { if (annotation == mapViewLocal.userLocation) { mapViewLocal.userLocation.title = @"Test"; [mapViewLocal setRegion:MKCoordinateRegionMakeWithDistance(mapViewLocal.userLocation.coordinate, 1000, 1000) animated:YES]; return nil; } MKPinAnnotationView *pinView = (MKPinAnnotationView*)[mapViewLocal dequeueReusableAnnotationViewWithIdentifier:@"Pin"]; if(pinView == nil)

How to check if annotation is clustered (MKMarkerAnnotationView and Cluster)

社会主义新天地 提交于 2019-12-03 15:11:55
问题 I'm trying to work with the new features added to the mapview in ios11. I'm clustering all my MKAnnotationView with circle collision but I have to check in real time when the annotation becomes clustered. I have no idea how to do that. EDIT (4/1/2018) : More informations : When I select an annotation I add a custom CallOutView when the didSelect method is called and remove the CallOut when the didDeselect method is called. The issue is when an annotation is selected and becomes clustered,

Putting UIButton and other UIControl objects inside an MKAnnotationView and allowing user interaction

女生的网名这么多〃 提交于 2019-12-03 13:17:49
I have a custom annotation view on the map, which has a UIButton in it, but the UIButton is not responsive when pressed. I have two main problems with user interaction on the annotation view: Buttons and other controls are not responsive. I want the annotation to block touches according to my implementation of - (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent*)event - that is if I return YES then I don't want the touches to get sent through to the MKMapView (potentially selecting other annotations that are BEHIND my annotation view), I want to handle the touch myself in this case. I have

show users location blue point in iPhone MKMapView

允我心安 提交于 2019-12-03 12:47:43
问题 I am developing a custom pins in a MapView in my iPhone app. Here is the code: - (MKAnnotationView *)mapView:(MKMapView *)mapView viewForAnnotation:(id <MKAnnotation>)annotation { static NSString *AnnotationViewID = @"annotationViewID"; MKAnnotationView *annotationView = (MKAnnotationView *)[myMapView dequeueReusableAnnotationViewWithIdentifier:AnnotationViewID]; if (annotationView == nil) { annotationView = [[[MKAnnotationView alloc] initWithAnnotation:annotation reuseIdentifier