When clicking on an annotation in a mapview, no event is generated for SDK 7.x/8.x but it’s working well for SDK 6.1.
For more details visit
var win2 = Ti.UI.createWindow({
barColor : '#ff0000',
extendEdges : [Ti.UI.EXTEND_EDGE_ALL],
});
var mountainView = Titanium.Map.createAnnotation({
latitude : 37.390749,
longitude : -122.081651,
title : "Appcelerator Headquarters",
subtitle : 'Mountain View, CA',
pincolor : Titanium.Map.ANNOTATION_RED,
animate : true,
leftButton : '/images/arrow.png',
myid : 1 // Custom property to uniquely identify this annotation.
});
var mapview = Titanium.Map.createView({
mapType : Titanium.Map.STANDARD_TYPE,
region : {
latitude : 37.390749,
longitude : -122.081651,
latitudeDelta : 0.01,
longitudeDelta : 0.01
},
animate : true,
regionFit : true,
userLocation : true,
annotations : [mountainView]
});
win2.add(mapview);
// Handle click events on any annotations on this map.
mapview.addEventListener('click', function(evt){
var clicksource = evt.clicksource;
alert(clicksource);
if (clicksource == 'title' || clicksource == 'rightButton'){
Ti.API.info('Item clicked');
}
});
win2.open();
So is this a bug that is going to be fixed anytime soon? hard to determine from the comments here... is there a workaround suggested.
[~aaron@clearlyinnovative.com] We are investigating and will let you know an approximate ETA.
The basic problem is how mapView fires the click event. On iOS it is fired when the annotation is selected or deselected, not when you click somewhere on the map. On iOS7 clicking on an annotation that is selected does not deselect the annotation (as it does on older versions of iOS). Hence it does not fire the click event. To fix this we would actually have to break existing behavior and redefine the events supported by the mapView. Right now as a workaround please use the leftbutton or rightbutton properties of the annotation and listen to the click event with the appropriate clicksource. We will address this in the next release.
Is there any progress on this issue? We require this feature for a customer's app.
[~vjoshi] Apologies, not yet. It will be addressed in version 3.3.0 of the SDK.
Issue is still reproducible on iOS 7. Tested on: Appcelerator Studio, build: 3.2.1.201401311225 SDK build: 3.2.0.GA, 3.2.1.v20140203160859 CLI: 3.2.1-beta3 Alloy: 1.3.1-cr Xcode: 5.0.2 Device: ipad 2 (7.0.4)
After investigation, this has more side effects than we previously thought. We need to move this to the next release. In the meantime, use the workarounds as suggested by Vishal.
Still an issue in 4.0.0.GA. No events fired when you tap on the title, subtitle, leftButton/View or rightButton/View. Simple example: https://gist.github.com/FokkeZB/1d2c98867f621798a5fa
TIMOB-19215 doesn't appear to be available publicly. Is there a way for the 16 or so non appc-employees watching this ticket to be able to track the new one?
this issue has been going on two years? and now we cannot track it any longer...
[~aaron@clearlyinnovative.com] [~adampax] it has been resolved and I've asked for the ticket to be made public.
There is still an issue with click event detection for "title" element. Tested on Iphone 6 with Ti.MAP version 2.3.3. and Titanium v 4.1.0 GA. Update: leftPane and leftView element clicks also dont throw events.
[~nradaev] The new ticket TIMOB-19215 says the issue has been resolved in SDK 4.1.1. You will need to wait until 4.1.1 is released or test with a [continuous build](http://docs.appcelerator.com/platform/latest/#!/guide/Installing_Titanium_SDK_Continuous_Builds)
Retested with 4.1.1 v20160816214204 and confirmed that issues described in my comment above +still present+.
You may want to post your findings on that ticket as well.
Closing ticket as duplicate, with reference to the above link, which was fixed in August 2015.