Selecting a location with MapKit - iphone

Is there a best practice or common pattern for allowing users to select a precise location on a map using MapKit?
I've seen examples where a user can enter an address in a search box. But what about the case where a user doesn't know the exact address and wants to select a location from the map?

It's a bit more complex task than it seems.
Here is the guide how to detect single taps on a Web View.
I've used the same pattern to detect single taps on Map View but allowing zooming and dragging at the same time.
Hope it helps.

I would say that replicating the Maps application is close to a best practice for map applications.
You can test it for yourself; tap and hold somewhere on the map and a pin that you can move around by dragging will be dropped where you held your finger.

The Google Maps app seems to tackle what is a reasonable idea by touching the map by instead allowing you to drop a pin on the map; the SO post might help out.

Related

Is GPS Spoofing possible in iOS sdk?

Is there any way in iOS to spoof the GPS location. I mean to say show user different coordinates not the real one ?
Thanks!
As far as i know gps gives you lat long and you show it on map.
What you can do is add your code in between to spoof obviously iam not talking about the default app. Look at heversine formula it will be helpfull
take care of water bodies and buildings you dont want to spoof the position of car in ocean iguess
the most easiest way to do that is make the map annotation you own,
you may look that this https://github.com/samvermette/SVPulsingAnnotationView
hide the original one & make a fake annotation view with any location you want

How do I create a Map Icon?

My app currently texts the user's GPS coordinates, after which the receipent enters them into the MAP app that comes with our iPhones. I just discovered that it is somehow possible to create an icon that the receipent merely clicks on to bring up the MAP app, where it displays a map showing the location of the coordinates, along with the exact address. I was so impressed with the accuracy and ease of use that I want to modify my app to text an icon, instead of the GPS coordinates. I spend all day researching but can't find how to do it. (Maybe I haven't looked in the right places, so please excuse me if I'm wasting time.)
The icon I'm trying to create (and text) is the one that you would create if you were looking at a location using the MAP app. After you tap the disclosure button it displays detailed info. At the bottom of the screen is a button entitled, "Share Location." If you click it, you then have the option of clicking another button entitled, "Message." a text message gets generated with an icon that represents a pin with a red head. This is what I'd like to create.
If it's possible, can somebody point me to where I can find more information, hopefully, including sample code?
Not all users have the ability to text images. The best option might be to just use the text... Also when you ask how to create the icon, what do you mean? The actual image?

MKMapViewDelegate notifing when user moved the map

I use an MKMapView in my application, and implement its delegate. As with the Google Maps, I want to know when the user moved the map.
If you open the Google Maps application, and press the GPS icon the button is set to the DONE style and the map centers to your location. Whenever you move the map the icon automatically gets back to PLAIN style.
How can I do the same thing?
Best regards,
Paul Peelen
I am not sure whether this will solve your problem. But try overriding regionDidChangeAnimated: method of MKMapViewDelegate.
Doc says: This method is called whenever the currently displayed map region changes. During scrolling, this method may be called many times to report updates to the map position. Therefore, your implementation of this method should be as lightweight as possible to avoid affecting scrolling performance.

MkMapView drop a pin on touch

I am struggling to unearth a standard way to drop a pin on a MkMapView based on a touch input. There probably isnt a standard way, but it is always worth asking. If I have to implement this myself is the best approach to add a Gesture Recogniser to pick up a tap on the map view.
Yes, you can use a UILongPressGestureRecognizer to do this.
This previous answer of mine has details with sample code:
How to add a push pin to a MKMapView(IOS) when touching?
To animate the drop, in viewForAnnotation, return an MKPinAnnotationView with animatesDrop set to YES.
I know that the Maps app has a separate button (under the curl of the map) that drops a pin. Hence that is kind of how I do it (though not under the map curl). I have not read anywhere that there is a standard but I have not read all 12,000 GB of documentation (ha ha). I would say to check out some of the "standard" apps like Maps and follow what they do just to be consistent. I know that typically a double tap zooms the map so I'm not sure that I would use that. Just my $0.02...

Simulating keyboard tap

Is there a way to programmatically tap a key, just as a user would so the key pop up animation takes place?
Yes, it's possible but a good amount of work. It depends what your goal is.
UISpec is a good place to start looking. If you are interested in simulating clicks for testing purposes, then you can just use the library. Otherwise, it would contain the source and pointers to how you can do it yourself.