[TIMOB-19215] Events on Map Annotation do not fire
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2015-08-13T03:04:57.000+0000 |
Affected Version/s | Release 4.0.0 |
Fix Version/s | Release 4.1.1 |
Components | iOS |
Labels | annotation, events, map |
Reporter | Fokke Zandbergen |
Assignee | Hans Knöchel |
Created | 2015-06-25T09:17:04.000+0000 |
Updated | 2016-07-15T23:36:40.000+0000 |
Description
There are some other tickets related to this, but since most of them show no activity, are old or cover only part of the problem, here's one ticket and test case that covers it all.
The following test case shows that the only 2 times a click-event that fires is when you tap a pin to open the annotation and when you tap the map to close the annotation. Tapping on the leftButton/View, rightButton/View, title or subtitle does not fire the event. Another bug is that the
clicksource
when you tap the map to close the annotation is annotation
and not map
.
Adding listeners directly to the leftView/rightView does not work either.
Test case
var map = require('ti.map');
var win = Ti.UI.createWindow();
var anOne = map.createAnnotation({
latitude:37.390749,
longitude:-122.081651,
title:"Appcelerator Headquarters",
subtitle:'Mountain View, CA',
leftButton: Ti.UI.iPhone.SystemButton.SAVE,
rightButton: Ti.UI.iPhone.SystemButton.SAVE
});
var lBtn = Ti.UI.createView({
backgroundColor: 'red',
width: 40,
height: 40
});
lBtn.addEventListener('click', function(e) {
console.error(e);
});
var rBtn = Ti.UI.createView({
backgroundColor: 'red',
width: 40,
height: 40
});
rBtn.addEventListener('click', function(e) {
console.error(e);
});
var anTwo = map.createAnnotation({
latitude:37.33182,
longitude:-122.0311837,
title:"Apple Headquarters",
subtitle:'Cupertino, CA',
leftView: lBtn,
rightView: rBtn
});
var mapview = map.createView({
region: {latitude:37.390749, longitude:-122.081651, latitudeDelta:1, longitudeDelta:1},
annotations:[anOne, anTwo],
});
win.add(mapview);
mapview.addEventListener('click', function(evt) {
console.error(evt);
});
win.open();
Logs
Jun 25 11:11:10 iPhone-Fokke LiveViewer[6105] <Warning>: [ERROR] {
annotation = "[object TiMapAnnotation]";
bubbles = 1;
cancelBubble = 0;
clicksource = pin;
index = 14;
map = "[object TiMapIOS7View]";
source = "[object TiMapIOS7View]";
title = "Apple Headquarters";
type = click;
}
Jun 25 11:11:11 iPhone-Fokke LiveViewer[6105] <Warning>: [ERROR] {
annotation = "[object TiMapAnnotation]";
bubbles = 1;
cancelBubble = 0;
clicksource = annotation;
index = 14;
map = "[object TiMapIOS7View]";
source = "[object TiMapIOS7View]";
title = "Apple Headquarters";
type = click;
}
PR: https://github.com/appcelerator-modules/ti.map/pull/110 Release 2.3.3: https://github.com/appcelerator-modules/ti.map/releases/download/iOS-2.3.3/ti.map-iphone-2.3.3.zip After merging the changes, new archives in master and 4.1.X backport: - Master: https://github.com/appcelerator/titanium_mobile/pull/7015 - 4.1.X backport: https://github.com/appcelerator/titanium_mobile/pull/7016
Reviewed and approved. PRs merged.
Just retested this issue and there is still no click event being thrown for "title" or "leftView". Tested with: 1) Device - IPhone 6 OS v 8.3 2) Appcelerator SDK - 4.1.1 v20160816214204 3) Ti.Map v 2.3.3
That is bad news, I am waiting for this fix...
The title and subtitle clicksources are not exposed in iOS (and have never been). And to receive the click event of a view (not button), simple make a click eventlistener on the view and handle its click there. This is done for performance purposes.
Ok, I think I can make that work, thank you Hans
Is there any way to detect click event on the bubble on IOS?
@Nikita We need that too. *On iOS:* What we did was create a View and added it to the 'leftView' of the Annotation, and then added a Click event Listener on that view. (so you can only tap the leftView to do what you want). Was not able to listen to the Bubble. *On Android:* We still have No Solution! That same code on Android does not show the leftView. Though in the Docs: [http://docs.appcelerator.com/platform/latest/#!/api/Modules.Map.Annotation-property-leftView] it says: leftView : Titanium.UI.View Left view that is displayed on the annotation. This is ignored if the leftButton property is set. _(no leftButton is set in our case)_ *Android: 3.1.0* & iOS: 3.2.0
@Nikita You mentioned: "At the same time everything works perfectly on Android." Can you give me a small pseudo on what you did for Android? is it possible to show the title, long/lat, and a view or image on the left, and was able to click on the bubble or the leftView?
@Joseph Gladly. However, I feel like this is not the right place to do that. I am a bit busy atm. I will reach you via email listed on your account with a snippet as soon as I can. Cheers!
Closing ticket as fixed. Verified that the MapView click event gets triggered for the following scenarios: * Pressing the pins. * Pressing the leftButton and rightButton in the annotation. *
clicksource
property contains the accurate object e.g. map, pin, TiUIView, leftButton, and rightButton; except for title and subtitle as per Hans's comment. * If you click on a view inside the the map annotation, then the view's event listener is triggered. Tested on: Appcelerator Studio, build: 4.1.1.201507141126 Appc CLI NPM: 4.1.0-2 Appc CLI Core: 4.1.3-6 SDK: 4.1.1.v20150816214206 ti.map: 2.3.3 Node: v0.10.38 OS: Yosemite (10.10.5) Xcode: 6.4 Devices: iphone 6 plus (8.3)