Animate coordinate changes to annotations on MKMapView - ios

Is it possible to animate changes to the coordinates of an annotation on an MKMapView in iOS? Nothing in the API seems to indicate that this is possible, however apps like Uber seem to do this when showing car locations in their map. Perhaps they are calling setCoordinate: multiple times over a short time to give the appearance of animation taking place?

Related

How to keep an MKAnnotation View Image fixed on the center of the map as the user pans and moves the map around (Swift)?

using target 8.0 MapKit, I would like to define an MKAnnotation (such as a pin, or a custom one) that remains fixed on the center of the map view as the user moves the map around. Once the user stops moving the map, I would like to be able to read the new coordinates of the annotation. How can I do this? This in swift, thank you soo much
You can follow this link to accomplish this task.They are doing something very similar to your requirement. Its quite descriptive. Link

Make a Mapbox RMAnnotation display its callout programmatically

I'm making an iOS app (using Swift) that has a map in the Mapbox iOS SDK. I've gotten to the point of displaying several markers on the map. Now, I want the user to be able to select a marker from the list, panning to that marker (easy), which also makes the marker's callout bubble appear automatically without the user having to touch it (not so easy).
It's this last task I'm having trouble with. While I've found the RMMarker class's showLabel() method, I can't seem to directly access a RMAnnotation's associated RMMarker object, so I'm not sure where or how to call this method.
Does anyone know how this is done?
Ignore the showLabel() API — this is not the callout in use, but rather a text label that's possible directly on the annotation.
You probably want -[RMMapView selectAnnotation:animated:] with a NO in the animated argument.

MapKit (iOS) -- Live MKAnnotation Motion

I'm designing an app using Swift for a food truck. I want to use MapKit to show a pin on the live location of the truck so one can look at the app to see it moving in realtime. I was able to get the server-side element set up using PHP/MySQL. Currently, the app makes a HTTP request every 3 seconds.
How should I go about animating the moving pin (or other image)? I tried a few methods already (if you have others, please suggest!):
I removed the pin and quickly added a new one in my HTTP function. While this works, I would prefer a smooth animation, not a flashing, jerky pin.
I subclassed MKMapViewDelgate like with a didAddAnnotationViews delegate that animates the pin's frame using UIView.animateWithDuration as suggested here. Animation only occurred when the map was initially loaded. Also, I have no idea how this would work with coordinates, since it involves frames.
I subclassed MKAnnotation with a modifiable var coordinate. In my HTTP function, I changed the coordinate. EDIT: This now works since I properly refreshed the mapView (thanks #Paulw11). However, I still have two main issues:
There's no linear animation, which I desire to better simulate real-time movement. How would I go about animating the pin's coordinates? Should I use UIView, like in method 2, a fast NSTimer, or something else?
Due to using the setCenterCoordinate function to forcibly refresh the map, the map cancels any current touches. How do I detect if there's any touches on the MapView so I can prevent the forced update?

snapshot/screenshot with MKMapview

I am trying to make a snapshot from a view with a MKMapview to provide a springboard like folder animation when the user selects an annotation.
The official way to make a snapshot of the current window is presented here. This works fine (though quite slow) unless the mapview is not zoomed in too much and has a "regionThatFits" set. The map & the marker make an unmatched "jump" to the left and the gridlines of the mapview are visible:
Before screenshot:
After screenshot:
I suppose it has something to do with the tiled parts of the map but I don't know how to prevent that behaviour.
Any thoughts?

A better way to mark location on a map

I'm making an iOS app, where I want users to mark locations on a regular basis on a map. The default way to mark location in iOS is to drop a pin either at the center of the map or where the user holds a touch (using the gesture recognizer).
Then to mark the pin to the desired location ACCURATELY, the user holds the pin and can drop it again. If you have done this on an iOS maps app, you will know it is hard to mark a location ACCURATELY, in this manner. It looks cool, but takes some trial and error in my opinion.
If I can help it, I want to make this process smoother and more obvious is my app.
So is there any other way for the user to mark a location on a map, without doing the default pin drag-drop? Any Suggestions welcome :-)
Just an idea... instead of moving the pin, you could move the map with the finger, and keep the pin always in the middle of the mapView (maybe marked with a crosshair or something). Then you can get the coordinates of the Pin using the "center" method of the mapView. That way you don't cover the pin / crosshair with your finger.
I recommend you have a look at the Maps app again. When you hold down your finger on a dropped pin, notice the location of bottom of the pin on the map. The pin actually drops in this exact location, after doing a quick bounce. The pin also sits about 20 above the users finger.
While it's not the most obvious, it's very accurate in my opinion. Enough to query the Geocoder API for an address, or just get coordinates. Keep in mind the GPS has an accuracy of 5-10 meters at the most. Zooming in will allow the user to go even more accurate.
But if this solutions isn't what you want, I'd overlay a point in the centre of the map and make sure it doesn't respond to touches, making it possible to move around the map underneath this point. When touched end, then drop a pin in the middle of the map where the point is. If touches begin again, pop out the pin from the map. I don't think a pin that's already on the map staying in place while the map moves independently will look good.

Resources