mkannotation

Making map pins spread out from a cluster

↘锁芯ラ 提交于 2019-12-04 14:29:56
I've got two custom annotation classes for my map: one for a single post tied to a location, and one for a cluster of those posts. The cluster stores pointers to all of the posts it contains, as well as a central lat/long location (calculated using the locations of the posts it contains). I have the behaviour that when I click on a cluster annotation it removes the cluster and adds its posts to the map. What I want is to change the pin-drop annotation when expanding the clusters to an animation whereby the new pins move outwards from the centre of the cluster to their new locations. However, I

Swift - setting rounded corners to annotation view image

房东的猫 提交于 2019-12-04 13:39:37
Here is my previous thread, where I set image to annotation view pins Swift - setting different images from array to annotation pins Right now I encountered a problem with setting rounded corners on annotation view image. cannot show callout with clipsToBounds enabled swift appears that I have to choose between rounded corners or showing callout, I don't really get why these two can't come along. Is there any way to do that? Here is my viewForAnnotation function: func mapView(mapView: MKMapView!, viewForAnnotation annotation: MKAnnotation!) -> MKAnnotationView! { if !(annotation is

How to change default background color of callout bubble with detailCalloutAccessoryView

夙愿已清 提交于 2019-12-04 10:28:31
In my app I have the following sutuation. I've implemented a custom callout bubble with custom detailCalloutAccessoryView with two labels inside. I know how to change the color of detailCalloutAccessoryView with this line. view.detailCalloutAccessoryView?.backgroundColor = UIColor.red But I can't figure out how to change background color of the main bubble (it is transparent grey/white now). With view.detailCalloutAccessoryView?.backgroundColor = UIColor.red line my calloutbubble looks like this: But I want my custom bubble to look like this: Here is my viewFor annotation method: func mapView(

Convert MKAnnotation Coordinates to View Coordinates

ⅰ亾dé卋堺 提交于 2019-12-04 04:35:34
问题 I am displaying a custom UIView when the user clicks on the pin (Like the Zillow app). Now the problem is that I need to place the view right above the actual pin. The MKAnnotationView coordinates system is related to the map. How can I get the coordinates with respect to the iPhone screen and then place my view on that coordinate. - (void)mapView:(MKMapView *)mv didSelectAnnotationView:(MKAnnotationView *)view { // get view from storyboard ZillowSearchResultAnnotation *annotation =

MapView Custom Pin Image Issue

雨燕双飞 提交于 2019-12-03 21:20:47
I have changed my MapView pin image but I am getting this problem that some of the point wont change the pin image and some of them change. Where would be the problem? I have added an example. My Code: - (MKAnnotationView *)mapView:(MKMapView *)mV viewForAnnotation:(id <MKAnnotation>)annotation { MKPinAnnotationView *pinAnnotation = nil; MKAnnotationView *pinView = nil; if(annotation != locationMap.userLocation) { static NSString *defaultPinID = @"myPin"; pinAnnotation = (MKPinAnnotationView *)[locationMap dequeueReusableAnnotationViewWithIdentifier:defaultPinID]; if ( pinAnnotation == nil )

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 = [

Grouped/Ungroup MKAnnotation depending on the zoom level (And keep it fast)

旧城冷巷雨未停 提交于 2019-12-03 18:46:06
问题 I have a mapview that has a lot of annotations, most of them are very close to each other. What I want to do is similar to the Photo app on iOS where annotations are grouped when they are too close to each other and whenever you zoom out, they un grouped if they are too far apart. I have seen this question already but the answer given isn't really what I was looking for. I'm looking for either a library or a algorithm that I could implement myself. 回答1: Have a look here in order to see the

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

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