Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2234] Android: Annotations with Google Maps V2 - Clicking on annotation's info window doesnt work

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionInvalid
Resolution Date2013-07-22T19:02:31.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules
Labelsn/a
Reporterdiego
AssigneeEduardo Gomez
Created2013-04-02T05:59:04.000+0000
Updated2016-03-08T07:41:14.000+0000

Description

*Problem* When the user clicks on an annotation's info window I need to perform an action, but I can't catch the event when the user clicks on the info window, only when the annotation pin is clicked. I read that this is a bug, and that you should be able to click on an annotation's info window to reveal another window to show more information. *Test case*
var MapModule = require('ti.map');
var win = Ti.UI.createWindow({
	backgroundColor : 'white'
});

map1 = MapModule.createView({
	userLocation : true,
	mapType : MapModule.NORMAL_TYPE,
	animate : true,
	region : {
		latitude : 37.389569,
		longitude : -122.050212,
		latitudeDelta : 0.1,
		longitudeDelta : 0.1
	},
	height : 'auto',
	top : 0,
	left : 0,
	width : 'auto'
});

var myAdd = MapModule.createAnnotation({
	latitude : 37.389569,
	longitude : -122.050212,
	title : "Appcelerator Headquarters",
	subtitle : 'Mountain View, CA',
	pincolor : Ti.Map.ANNOTATION_GREEN,
	myid : 1
});

//the next eventListener only works when you click de Annotation and not the little white box information.
myAnotation1.addEventListener('click', function(e) {
	alert("Annotation popup clicked");
});
map1.addAnnotation(myAnotation1);
win.add(map1);
win.open();

Attachments

FileDateSize
bug map annotation.png2013-04-03T00:19:29.000+0000551906

Comments

  1. Jamie Buckley 2013-04-02

    Hi Diego, Can you please provide some additional information on this issue: - Titanium Studio Version - Titanium SDK Version - Small Reporducible test case You can see the full guidelines of how to submit a ticket here: https://wiki.appcelerator.org/display/guides/How+to+Submit+a+Bug+Report
  2. diego 2013-04-03

    Titanium Studio, build: 3.0.2.201302191606- 19022013160949 Titanium SDK: 3.0.2 GA Note:new image attached. if you click on the red point (Annotation) the event trigger works! so the little white box with 'title' and 'subtitle' comes up, and additionally you can put some piece of code in this event which is called from the code in this way: myAnnotation.addEventListener('click', function(e){ //some stuff }); ok, everything looks good, but... when i try to click the little white box information displayed from the annotation (surrounded with green frame in the attached image)there is the problem! it does not have any event, so i canĀ“t do anything when i want to click this little box, and other platforms y saw that you can really do! but i dont know why in Titanium this is imposible. I think it is not necessary a small reproducible test case, but anyway here is a little piece of code: [Moved to description]
  3. Eduardo Gomez 2013-07-22

    Event Handling

    Closing as invalid. The Map View object provides a few extra events that provide additional control for using the Map module: click - This event only fires when the user selects or deselects an Annotation object and does not respond to any other user interaction. Check the event object's annotation property to see which annotation was clicked and the clicksource property to see what part of the annotation the user clicked.

    Simple sample

       var MapModule = require('ti.map');
       var win = Ti.UI.createWindow({
       	backgroundColor : 'white'
       });
       var appc = MapModule.createAnnotation({
       	latitude : 37.389569,
       	longitude : -122.050212,
       	title : 'Appcelerator HQ',
       	subtitle : 'Mountain View, CA',
       	pincolor : MapModule.ANNOTATION_GREEN,
       	draggable : true
       });
       var mapview = MapModule.createView({
       	mapType : MapModule.HYBRID_TYPE,
       	region : {
       		latitude : 37.389569,
       		longitude : -122.050212,
       		latitudeDelta : 0.2,
       		longitudeDelta : 0.2
       	},
       	annotations : [appc]
       });
       mapview.addEventListener('pinchangedragstate', function(e) {
       	Ti.API.info(e.type);
       	Ti.API.info(JSON.stringify(e.newState));
       });
       
       mapview.addEventListener('click', function(e) {
       	Ti.API.info(e.type);
       	Ti.API.info(JSON.stringify(e.clicksource));
       });
       
       mapview.addEventListener('regionchanged', function(e) {
       	Ti.API.info(e.type);
       	Ti.API.info(e.latitude + "," + e.longitude);
       });
       
       mapview.addEventListener('complete', function(e) {
       	Ti.API.info(e.type);
       });
       
       win.add(mapview);
       win.open(); 
       

    Output

       07-22 13:58:25.052: I/TiAPI(4903):  click
       07-22 13:58:25.052: I/TiAPI(4903):  "pin"
       07-22 13:58:25.935: I/TiAPI(4903):  click
       07-22 13:58:25.935: I/TiAPI(4903):  "subtitle"
       

    Further reading

    http://docs.appcelerator.com/titanium/latest/#!/guide/Google_Maps_v2_for_Android-section-36739898_GoogleMapsv2forAndroid-EventHandling
  4. Shak Hossain 2013-12-28

    Closing since we have not heard back from the reporter and a functional sample has been posted by [~egomez]

JSON Source