Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-16242] Android: Map V2 - Click event in map annotation is not working in leftview

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionWon't Do
Resolution Date2020-02-19T13:44:50.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAndroid
LabelsV2, android, annotations
ReporterArmindo Da Silva
AssigneeAshraf Abu
Created2014-01-16T10:48:28.000+0000
Updated2020-02-19T13:44:50.000+0000

Description

When using leftView controls doesn't respond to events. I have tried first to put a view with buttons, no event fired when clicking on buttons. Then I have built a new sample with just a button as leftView, same problem. Another problem, the rightButton property doesn't show the image, I have tried with different path string, same problem. Last problem : I have always this error message in console : GooglePlayServicesUtil: The Google Play services resources were not found. Check your project configuration to ensure that the resources are included. but it is installed in Android sdk and in device also. I'm not alone having this problem. here's a sample code :
var MapModule = require('ti.map');
var win = Ti.UI.createWindow({backgroundColor: 'white'});
 
var btn = Ti.UI.createButton({title: 'Detail'});
 
btn.addEventListener('click',function(e)
{
   Titanium.API.info("You clicked the button");
});
 
var bridge = MapModule.createAnnotation({
    latitude: -33.852222,
    longitude: 151.210556,
    pincolor: MapModule.ANNOTATION_AZURE,
    // Even though we are creating a button, it does not respond to Button events or animates.
    // Use the Map View's click event and monitor the clicksource property for 'leftPane'.
    leftView: btn,
    // For eventing, use the Map View's click event
    // and monitor the clicksource property for 'rightPane'.
    rightButton: '/images/boston_college.png',    
    title: 'Sydney Harbour Bridge',
    subtitle: 'Port Jackson'
});
 
 
var mapview = MapModule.createView({
    mapType: MapModule.NORMAL_TYPE,
    region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 },
    annotations: [bridge] //< add these annotations upon creation
});
 
win.add(mapview);
win.open();

Comments

  1. Armindo Da Silva 2014-01-19

    Have you tried my code ? Map View's click event also is not usable because you always have rightPane as click source, you never have the button. And strange thing when you click on the button, the annotation bubble becomes blue, like if there is a view on top of it. also why rightButton or leftButton doesn't display it's image ?
  2. Armindo Da Silva 2014-01-22

    pff no comments no reply on Q&A board, I'm stuck since 2 weeks because I cannot publish my app and my customer is grommeling. Probably the time to switch to "Real" native dev tools.
  3. Hieu Pham 2014-02-12

    1.The left/rightView are converted to a bitmap so you can't really use button click event listener, you need to use map 'click' listener and look for clicksource of 'leftPane'. 2. I'm seeing the right image with no problem... 3. That error indicates that the resources are missing from google play services. This is due to our current limitations of using native module as a dependent for modules. This should be fixed soon.
  4. Armindo Da Silva 2014-02-13

    1 - the problem of clicksource is that I use the view with 3 buttons on it and no way to know which control receive the click event, in the previous version of map I had no problem. 2 - I can confirm you that right or left image is not shown.
  5. Hieu Pham 2014-02-14

    Hi Armindo, 1. The clicksource will return different values if users click on different views. The possible values for 'clicksource' are: pin, title, subtitle, leftPane, rightPane, infoWindow or null. Please see http://docs.appcelerator.com/titanium/latest/#!/api/Modules.Map.View-event-click for more details. 2. Can you attach the project that you are having issues with?
  6. Armindo Da Silva 2014-02-14

    Dear Hieu, what I mean is that I use on the left View, a TUIView with 3 TUIButtons inside it (just imagine a panel with 3 buttons on it), so for instance when the use click on the pin he has the choice to click on pictures, videos or some infos, so 3 buttons on this view. The problem if I click pn one of these three buttons is that the click source is always 'leftPane', no way to know which button was clicked…. Things that I was able to do previously. Now I'm stuck, all the app is based on this.
  7. Armindo Da Silva 2014-02-14

    Here's a sample code :
       // for creating the view :
       function createTheProjectView(selectedMapId) {
       
       					
       		var projectAnnotView = Titanium.UI.createView({
       			height : '32dp',
       			width : '110dp'
       		});
       
       		var projectPhotoBtn = Titanium.UI.createButton({
       			left : "2dp",
       			width : "32dp",
       			height : "32dp",
       			backgroundImage : '/images/photo.png',
       			backgroundDisabledImage : '/images/photo_disabled.png',
       			backgroundSelectedImage : '/images/photo_over.png'
       		});		
       		projectAnnotView.add(projectPhotoBtn);
       
       		var projectCameraBtn = Titanium.UI.createButton({
       			left : "38dp",
       			width : "32dp",
       			height : "32dp",
       			backgroundImage : '/images/video.png',
       			backgroundDisabledImage : '/images/video_disabled.png',
       			backgroundSelectedImage : '/images/video_over.png'
       		});
       		projectAnnotView.add(projectCameraBtn);
       
       		var projectDetailsBtn = Titanium.UI.createButton({
       			left : "74dp",
       			width : "32dp",
       			height : "32dp",
       			backgroundImage : '/images/information.png',
       			backgroundDisabledImage : '/images/information_disabled.png',
       			backgroundSelectedImage : '/images/information_over.png',
       		});		
       		projectAnnotView.add(projectDetailsBtn);
       		
       		return projectAnnotView;
       	};
       
       when creating annotations :
       var annotation = Map.createAnnotation({
       				latitude : lat,
       				longitude : lon,
       				title : dat.title,
       				subtitle : dat.comment,
       				leftButton : '/images/marqueurProjet.png',
       				dataId : i, // Custom property to uniquely identify this annotation.
       				rightView:createTheProjectView(i),
       				video : dat.video,
       				images : dat.images
       			});
       
    Hope this help.
  8. Armindo Da Silva 2014-02-18

    I can confirm you also that pinImage, rightButon image and leftButton image doesn't work when you use something like image : '/images/marqueurProjet.png' you always have to use image : 'marqueurProjet.png' and you have to pout the image in the resource folder, this is not a good thing to do when you want to deal with multiple densities on Android. this bug has already been reported about a year ago in different places : https://developer.appcelerator.com/question/149070/android-google-map-v2-issue

JSON Source