Titanium JIRA Archive
Appcelerator Modules (MOD)

[MOD-2442] Android: MapView with clustering does not send click event

GitHub Issuen/a
TypeBug
PriorityHigh
StatusResolved
ResolutionFixed
Resolution Date2018-08-17T21:52:04.000+0000
Affected Version/sn/a
Fix Version/sTi.Map Android 4.3.1
ComponentsMap
Labelsn/a
ReporterYordan Banev
AssigneeYordan Banev
Created2018-07-25T09:52:52.000+0000
Updated2018-08-17T21:52:04.000+0000

Description

When using a MapView with clustering support clicking an Annotation not in a cluster does not trigger a click event, but opens the InfoWindow. *Sample code:* _app.js_

var MapModule = require('ti.map');
    var win = Ti.UI.createWindow({ backgroundColor: 'white' });
    var opera = MapModule.createAnnotation({
        latitude: -33.8569,
        longitude: 151.2153,
        centerOffset: { x: 80, y: 25 },
        pincolor: MapModule.ANNOTATION_RED,
        //image: 'SydneyOperaHouse.jpg',
        title: 'Sydney Opera',
        subtitle: 'Sydney, New South Wales, Australia',
        // For eventing, use the Map View's click event
        // and monitor the clicksource property for 'rightButton'.    
        //rightButton: Ti.UI.ios.SystemButton.CONTACT_ADD
    });



    var mapview = MapModule.createView({
        mapType: MapModule.NORMAL_TYPE,
        region: { latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 },
        annotations: [opera]
    });

    win.add(mapview);

    mapview.addEventListener('click', function(e) {
        if (e.annotation === opera) {
            mapview.removeAnnotation(opera);
            opera = null;
            opera = MapModule.createAnnotation({
                latitude: -33.8569,
                longitude: 151.2153,
                pincolor: MapModule.ANNOTATION_BLUE,
                //title: 'Test Annotation'
            });
            mapview.addAnnotation(opera);
        }
    });
win.open();

Comments

  1. Yordan Banev 2018-07-25

    PR: https://github.com/appcelerator-modules/ti.map/pull/239
  2. Michael Gangolf 2018-07-25

    Not working correctly for me.
       var Map = require('ti.map');
       var win = Titanium.UI.createWindow();
       var mapview = Map.createView({
       	width: Ti.UI.FILL,
       	height: Ti.UI.FILL,
       });
       
       function addData() {
       	var ann = [];
       	for (var i = 0; i < 10; i++) {
       		ann.push(Map.createAnnotation({
       			clusterIdentifier: (i % 2 == 0) ? 'cluster' : null,
       			collisionMode: Map.ANNOTATION_VIEW_COLLISION_MODE_RECTANGLE,
       			showAsMarker: true,
       			markerGlyphText: i.toString(),
       			markerColor: 'blue',
       			markerGlyphColor: 'green',
       			title: 'Title',
       			subtitle: 'subtitle',
       			markerTitleVisibility: Map.FEATURE_VISIBILITY_VISIBLE,
       			markerSubtitleVisibility: Map.FEATURE_VISIBILITY_HIDDEN,
       			markerGlyphImage: 'Flag.png',
       			markerSelectedGlyphImage: 'social-facebook-icon.png',
       			annotationDisplayPriority: Map.FEATURE_DISPLAY_PRIORITY_DEFAULT_LOW,
       			latitude: Math.random() * 10 + 40,
       			longitude: Math.random() * 10,
       			image: (i % 2 == 0) ? "img1.png" : "img2.png"
       		}));
       	}
       	mapview.setAnnotations(ann);
       }
       function onCluster(e) {
       	var clusterAnnotation = Map.createAnnotation({
       		showAsMarker: true,
       		markerText: e.memberAnnotations.length.toString(),
       		title: 'Cluster Title',
       		subtitle: 'Cluster Subtitle',
       	});
       	mapview.setClusterAnnotation({
       		annotation: clusterAnnotation,
       		memberAnnotations: e.memberAnnotations
       	});
       
       }
       
       mapview.addEventListener('clusteringstarted', onCluster);
       win.add(mapview);
       addData(); 
       
       mapview.addEventListener("click", function(e) {
       	console.log(e.clicksource)
       })
       win.open();
       
    that are not inside a cluster return "pin" but annotations inside a cluster - that are visible when zooming in - only open the infobox but won't return "pin"
  3. Yordan Banev 2018-07-27

    [~michael] I have updated the PR. Would you be able to give it a shot now?
  4. Michael Gangolf 2018-07-27

    [~ybanev] much better now! Click on the cluster still zooms, click on each annotation (normal or out of a cluster) fires the "pin" source. I like the removal of the TiClusterMarker so it's easier to handle the items!

JSON Source