I have a map with big pictures for annotations and when coordinates close to each other - one annotation is over another. Is there any methods to see them both entirely?
You can do some annotation clustering and display one annotation for both coordinates. If you really want to see them both and do not need to be exact shift them a bit like done in here
Handling MKMapView Annotation Pins on the Same Coordinate
But if you do care about precision detect the distance between two annotations. You want the distance on the screen not on the map. If the distance is over some treshold, you can present with two rotated annotations one reaching to the left and one to the right side. More can be studied from stuff written on topic of annotation clustering. Search on stack there is a ton of it.
I found better solution !
Change
#property (assign, nonatomic) CGSize clusterAnnotationViewSize to set a size of your own annotation and it will do everything. Also this pod implements same thing, as mentioned earlier.
Related
I'm using a MKMapView and use annotations with custom MKAnnotationViews in order to display other person's locations. Although, as the location of other people have error margins, I would like to represent the error margin just like the blue circle around your current location. I looked in the documentation of MKAnnotation and MKMapViewDelegate but couldn't find anything related. Is it possible to achieve this? If yes, how?
I found out that it wasn't actually possible. Although, I could draw the accuracy circle myself, by using an MKCircle with the accuracy radius and implementing mapView:rendererForOverlay: on the MKMapView's delegate.
Im working with Mapkit and I trying to draw a line in the "sidewalks" (border of the street),right now I'm looking for ideas on how I could start this task, thanks for your help.
notes: I know how to works with mkpolyline and coordinates
http://s30.postimg.org/7rnmdjzu9/mapa.png
You do not have access to the information that qualifies as a road inside the MKMapView. so, in order to be able to draw into the border of the street you will need to access the information that qualifies as a street (the coordinates of the road) or analyzing the view and changing the specific color represented by the border of the street (this is not public API, you will need to dig around the view hierarchy).
What is a good enough method of knowing when to go out to the server and request for annotations?
i.e. knowing when the area on the screen was not yet exposed by the user?
If I have a LAT1,LON1 LAT2,LON2 specifying the screen boundaries, or maybe the screen's center as LAT,LON, how can I know that the surface the user has moved to has never been exposed or even just a part of it?
Weird, but I can't find ideas online, Any methods would be welcome!
Thanks!
store a set of MKMapRect objects that the map showed in a NSMutableSet maybe -- you then have all the areas that were visible previously. (combine rects when it makes sense to keep the set reasonable)
when you get a new MKMapRect (after a scroll or zoom of the map view -- the delegate is informed here) see if the new visibleMapRect lies within an old one or just intersects or is not inside the rect at all
an MKMapRect can be treated almost like a CGRect :)
I need to draw many (hundreds to thousands) of square overlays on a map. The positions and sizes of these overlays stay constant. I think that I can speed up rendering by combining these square overlays into a single overlay so drawMapRect only needs to be called once. Is this possible?
In my case, removing overlays is not an option. A way I found to drastically improve performance was to have my overlay class store an array of the square overlays. Then in my overlayView's drawMapRect method, I looped over the array to draw all the overlays. Something very similar is done in the HazardMap Apple Developer Example. See drawMapRect in HazardMapView.m
I had similar problem for MKAnnotation.
And I found following link:
http://www.fiveminutes.eu/having-fun-with-ios-map-kit-grouping-annotations/
Iterate annotation list and calculate a distance of two annotation's coordinate.
If there's nearby annotation exist, remove it from the list.
I think this approach can be applicable to MKOverlays too.
I'm adding annotations to an MkMapView and am using a custom image to do so. My custom image is box shaped with a little triangular arrow that's supposed to be right on the place that's being annotated. It seems like MapView by default annotates using the geometric center of the image. What's the best way to design around this problem? Manually moving the icon? Creating the icon in a specific way?
Here's the Apple docs for MKAnnotationView's centerOffset property:
By default, the center point of an annotation view is placed at the coordinate point of the associated annotation. You can use this property to reposition the annotation view as needed. This x and y offset values are measured in pixels. Positive offset values move the annotation view down and to the right, while negative values move it up and to the left.