Multiple annotations (MKAnnotationView) in the same place Coordinates

Hey. I am trying to implement annotation grouping and animation if the user has touched.

I looked at another solution of the cluster library, but this does not work for me, because I have several annotations in the same coordinates.

So this is what I want to do

1- I determine where several annotations are in the same place (coordinates)? how to implement it? Find annotations in the same coordinates and create a new group annotation?

2- change the color of this annotation (to inform the user) I can do this using this method -(MKAnnotationView*)mapView:(MKMapView *)mapView viewForAnnotation:(id<MKAnnotation>)annotation;

3, if the user touches the annotations in this group, the annotations will move in a circle around their location.

As long as I have all my annotation on the map, some have a very dark shadow.

Now I want to concentrate on the first task - grouping

I do not ask for sample code, I can do this, I just need to figure out which methods to use to implement the task.

Annotations idea

Thank you for your help.

+4
source share
2 answers

I have finished implementing this code from StormID

Handling MKMapView annotation contacts at the same coordinate

I need to make some changes, but it works fine.

all done

+5
source

To get rid of the dark shadow caused by complex representations of annotations, I would mapView:viewForAnnotation: your mapView:viewForAnnotation: to find out when the transmitted annotation has the same coordinates as the other and returns only a view (of a different color) for one of these annotations.

Then, for your animation, when touching a grouped annotation, I would set mapView.scrollEnabled = mapView.zoomEnabled = NO temporarily for simplicity, hide the group annotation, and create an overlay with animating individual annotations myself. On the other hand, animate them back to the center, delete them and the overlay and show the combined annotation and turn on the map again.

0
source

Source: https://habr.com/ru/post/1479205/


All Articles