Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-19215] Events on Map Annotation do not fire

GitHub Issuen/a
TypeBug
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2015-08-13T03:04:57.000+0000
Affected Version/sRelease 4.0.0
Fix Version/sRelease 4.1.1
ComponentsiOS
Labelsannotation, events, map
ReporterFokke Zandbergen
AssigneeHans Knöchel
Created2015-06-25T09:17:04.000+0000
Updated2016-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;
	}

Comments

  1. Hans Knöchel 2015-08-10

    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
  2. Chee Kiat Ng 2015-08-13

    Reviewed and approved. PRs merged.
  3. Fokke Zandbergen 2015-08-13

  4. Nikita Radaev 2015-08-18

    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
  5. Claus Stilborg 2015-08-18

    That is bad news, I am waiting for this fix...
  6. Hans Knöchel 2015-08-18

    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.
  7. Claus Stilborg 2015-08-18

    Ok, I think I can make that work, thank you Hans
  8. Nikita Radaev 2015-08-18

    Is there any way to detect click event on the bubble on IOS?
  9. Joseph Sachs 2015-08-20

    @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
  10. Nikita Radaev 2015-08-20

  11. Joseph Sachs 2015-08-20

    @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?
  12. Nikita Radaev 2015-08-20

    @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!
  13. Wilson Luu 2015-08-24

    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)

JSON Source