Uploaded image for project: 'Appcelerator Modules'
  1. Appcelerator Modules
  2. MOD-2401

Ti.Map: Inconsistency between iOS and Android click events on Annotations

    Details

    • Type: Improvement
    • Status: Resolved
    • Priority: Medium
    • Resolution: Fixed
    • Affects Version/s: Release 7.1.0
    • Fix Version/s: Ti.Map Android 4.3.1
    • Component/s: Map
    • Labels:
    • Environment:

      Android
      TiSDK 7.1.0.RC

      Description

      In ti.map when selecting an annotation on the map a click event is triggered. When selecting another annotation on iOS 2 events are fired for both annotations (a deselect event, and a select event for the new one).

      On Android only a click event is triggered for the newly selected annotation.

      Some sample code

      var clickedAnnotation = null;
      function handleMapClick(e){
          // check if annotation was clicked
          if (e.hasOwnProperty('annotation')){
              
              // check if the annotation was selected or deselected based on previous state
              if (e.annotation.id == clickedAnnotation){
                  log.args('annotation deselected', e.annotation);
                  clickedAnnotation = null;
              } else {
                  log.args('annotation selected', e.annotation);
                  clickedAnnotation = e.annotation.id;
              }
          } else {
              if (e.clicksource == 'circle'){
                  log.args('circle clicked', e.latitude, e.longitude);
              }
          }
      }
      

          	<Module method="createView" module="ti.map" id="mapview" onClick="handleMapClick">
          		<Annotation id="amsterdam"></Annotation>
          		<Annotation id="appcHQ"></Annotation>
          	</Module>
      

      "#mapview": {
          region: {
              latitude: 37.359996,
              longitude: -121.950208,
              latitudeDelta: 0.6,
              longitudeDelta: 0.6
          }
      }
       
      "#amsterdam": {
          latitude: 52.39,
          longitude: 4.89,
          title: "Amsterdam",
          subtitle: "This is Amsterdam!",
          pincolor: Alloy.Globals.Map.ANNOTATION_RED
      }
       
      "#appcHQ": {
          latitude: 37.368122,
          longitude: -121.913653,
          title: "Appcelerator Headquarters",
          subtitle: "San Jose, CA",
          pincolor: Alloy.Globals.Map.ANNOTATION_RED
      }
      

      Result with example code
      When selecting an annotation you'll get a this in the console

      log.args('annotation selected', e.annotation);

      When selecting another one, you'll get both deselected and selected on iOS. But only selected on Android.

      Expected behaviour
      Consistency across platforms. Either create a click event for both annotations when selecting another, or only trigger a click event for selecting the annotation. The first is preferred in my opinion as that is consistent with other situations (like clicking on the canvas/circle after selecting an annotation).

        Attachments

          Activity

            People

            • Assignee:
              ybanev Yordan Banev
              Reporter:
              topener Rene Pot
              Reviewer:
              Gary Mathews
            • Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Git Source Code