Add a UIView at specific coordinates to a MKMapView - ios

I want to add a UIView to fixed coordinates on the mapview like a annotation. To be more specific the UIView should stay fixed at these coordinates on the mapview when the mapview is in interaction (moving, zooming, etc.) exactly the same like a annotation does it.
I tried to solve it with MKMapPoint but without success.
Hope someone has a tipp!

As I understand you want to use custom annotatin view. There is an answer for that question. I dont think you can use a UIView as you described.
How to create Custom MKAnnotationView and custom annotation title and subtitle

Related

iOS Swift MKMapView set overlay in front of map, behind annotation view

Here's an image of what I'm trying to accomplish:
Basically, a "dimmed" map.
The problem: The user needs the capability to pan the map, so just adding a semi-transparent view over the map won't do. (Adding a view over the mapView means it won't be able to detect gestures.)
Things I've tried:
Setting mapView backgroundColor
Adding a semi-transparent view using mapView.insertSubview
Setting mapView alpha (affects all children, i.e. annotation views)
MKOverlay (I've only found ways to set a view/polygon by coordinates)
is it possible to subclass a view that you can add as a semi-transparent subview, and give it a new variable called "map". This map variable would be a reference to your actual map. Add gesture recognizers for the subview, and when some sort of gesture takes place, pass the gesture to the map.
or add the gesture recognizers to the subview, and in the gesture recognizer, say map.runFunctionForThatGesture
I haven't done this myself, but I think it should work

Don't resize annotation on MKMapView zoom-in/out

Here is my code: https://ghostbin.com/paste/mvhdx
When my view is zoomed-in/out, the annotations resize. Is there a way to disable this behavior and keep the annotations at the size that they were created at?
Another bonus question, how do you prohibit a MKAnnotationView from rotating as well?
If you want to create shapes that are fixed to geography, you may want to look at overlays instead of annotations.
iOS7AnimatedMapOverlay shows how to add overlays to annotations.

How to use animated custom Pin (gif image) inside Mapview?

I want to add multiple pins on map which should remain animated continuously. Below are sample images which I want to use as Pin,
Is there any possible way to get this type of animated pin within MapKit? If possible then please suggest me appropriate way for it.
As per my knowledge it is quite tough to implement. You can easily implement animation on any UIImageView but when you add any image on custom image then you can change custom pin image via using KVO or via NSTimer.
Please follow Animation with MapView Custom Pin link to better understanding with custom pin annotation.
You can change pin image too after a certain period of time like as Zooming change pin image
and Custom pin animation - MKMapView.
I hope it will help you to better understanding. Thanks
You could create a custom MKAnnotationView and give it a UIImageView as a subview.
Then, split the GIF into separate frames, to use in the UIImageView, as documented in this SO question.

Strange positioning after using MKAnnotationView centerOffset

in iOS 5.0, I first place annotations on the map and also set the centre offset to CGPointMake(0,-annotationView.frame.size.height/2); right after setting the custom image for the annotation in the mapView:viewForAnnotation: method... after this the pins still appear at the original position which would be the case when the centre offset was not applied.
However, when I pinch or zoom the map, the annotation jumps to the correct position as would be the case with the centerOffset being set and then behaves correctly..
What could be the reason and solution for this?
Any help would be much appreciated.
Baffled!!
I was finally able to solve it by subclassing the MKAnnotationView and in the initWithAnnotation:reuseIdentifier: constructor method, synchronously get the annotationView image and then set the centerOffset to CGPointMake(0.0, -img.size.height/2);
If there are too many annotations, this will slow down the display of annotations, so would need to handle that differently.

Animated markers on Mapkit

Is it possible to draw sprites or fluent animated markers over a Mapkit Google map?
Thanks
It was pretty easy to include an animation for MKAnnotation.
You just need to add an animated UIImageView as a subview inside the MKAnnotationView you return for viewForAnnotation: method for that particular annotation.
Try by making custom markers and than add animated UIImageview.

Resources