[TIMOB-14494] iOS: Ti.Map should handle touch events on the view not just annotations
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | Low |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2018-01-29T03:41:33.000+0000 |
Affected Version/s | Release 2.1.4, Release 3.1.0, Release 3.1.1 |
Fix Version/s | n/a |
Components | iOS |
Labels | Ti.map, Titanium, iOS, mobilesdk |
Reporter | Ashish Nigam |
Assignee | Vijay Singh |
Created | 2013-07-08T13:36:20.000+0000 |
Updated | 2018-08-06T17:41:08.000+0000 |
Description
Touch events are currently only fired on Map Annotations and not else where on the map view.
Implement touch events on the Map View.
I'm looking at this now, but have concerns. [Apple's documentation](https://developer.apple.com/library/ios/documentation/MapKit/Reference/MKMapView_Class/MKMapView/MKMapView.html) says, "Although you should not subclass the MKMapView class itself, you can get information about the map view’s behavior by providing a delegate object." We currently do, but this delegate gets events that are NOT the simple touch events. I'm currently looking at the feasibility of subclassing Map View anyways, to see if that even is a solution; it's possible that the event handling is done deep in the private bowels of MKMapView. The other option may be with gesture recognizers, but these are NOT the same as the touch handlers. May I enquire as to what you're trying to do with these listeners? Maybe there's a different solution that works better.
Update: With a subclass of MKMapView, and listeners of the touch events, it turns out that the actual panning is started with a touch cancelled event. In other words, natively, the view events for moving about the map are: * touchstart once * touchmove three times before the map starts to pan. * touchcancel once as the map starts to pan. * never does a touchend event happen. A double-tap on the map is as follows: * touchstart once * touchcancel once as the map logic overrides. * never does a touchend event happen, nor a second touchstart. I am not sure that providing this behavior would be sufficient and meet the customer's needs.
Looks like gestures won't help with panning or zooming either, unfortunately. Similarly, gestures for double-taps don't work, either. It's highly likely that we will not be able to provide touch events, due to the design of MKMapView. I don't want to resolve it as "Not our bug" (IE, Apple's fault) just yet without asking again: What is the intent? Is there a way we can create customer success by another means?
Need information from the customer about what functionality they need. It's highly likely that iOS's MKMapView is such that this information cannot be provided.
Actually, looking at this, we already fire a click event for an annotation selection and deselection.
Please reopen with sample
Here is an sample app https://github.com/AppceleratorSolutions/TitaniumProjects/tree/master/MapExtensions This current solution for custom annotations that Alan created works great ... but the only way to close or remove an annotation from the screen is to move the map or click on another annotation. Other well done mobiles app, such as Zillow, Trulia, etc will remove the annotation from the map when the map is simply touched. We need the same user experience to happen in order to have a complete solution to what Alan has provided.
I'm having similar trouble. We need our callout to handle click events. From what Apple's documentation says, subclassing MKMapView is both unwanted and unnecessary for this. A slight modification of TiMapCustomAnnotationView should be sufficient. Override (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event This should be used to return YES if point is in a non-transparent area of theProxy. That should fix the problem with (UIView *)hitTest:(CGPoint) point withEvent:(UIEvent *)event not returning a view when the callout is clicked. This will enable clickable callouts. I really need this feature today. I was trying to rebuild the map module for myself but ended up with an error that didn't make sense to me. Traceback (most recent call last): File "./build.py", line 220, in
Deferring this due to lack of bandwidth this sprint.
"mapclick" event get supported as part of MOD-2322.
Closing as a duplicate. If this is in error, please reopen.