When the user "force touch" on the map view annotation right image, we should catch the peek event listener for that annotation view and display a custom view with some actions like show direction, call etc.
In the application, customer is showing the addresses of the doctors available with in 25 km radius of the user selected location on a map view.
There can be 25 pins near by the user selected location, all these locations are shown as annotations. when the user taps on a particular annotation the info should be displayed as title and subtitle of the annotation.
Also there will be a right image in the annotation, below are the events expected to be performed on tap or force touch of the annotation.
- Create a new classic app mobile project
- Paste the code
- Try The "Peek & pop"
1. When the user taps (click event of the map view annotation) on the annotation we should be displaying a view or optional dialog with different options like directions, call and profile.
2.When the user "force touch" the map annotation on the devices which supports the peek & pop functionality (iPhone 6s and above), we should catch the peek event and display a custom preview view with options call, directions and profile.
A. Tapping on the directions option should take the user to google maps with route plotted between the user current selected location and the doctor location.
B. Tapping on the call option will place a call to doctors phone number.
C . Tapping on the profile take the user where more detailed information of the doctor is shown.
Limitations or Problems:
1. There is no " Preview Context" property for the annotation directly.
2. There is "Preview context" property for the map view, but we want to implement this feature only on the force touch of right image in annotation.
3. Applying "Preview Context" for map view does not suffice our requirement as we are not getting the source in the map view peek event.
4. Tried achieving this adding a custom right view to the annotation. But the right view is not rendered properly, there are some limitations. Below are some:
a) Unable to add a label or button or image view as right view to annotation.
b) able to add only a plain view to the annotation right view. if we are creating a view and adding label, button or image view to that view and setting the view as right view of annotation, right view is not rendered.