Uploaded image for project: 'Titanium SDK/CLI'
  1. Titanium SDK/CLI
  2. TIMOB-10009

Android: Mapview centers on selectAnnotation, parity with iOS

    Details

      Description

      Issue

      Given a map view, if we call "selectAnnotation" on a particular annotation, the map will automatically center on that annotation. If the map height is very small the top of the annotation can be cut off. The map should not center but should bump the map up north of the annotation so that it is fully visible, just like it happens on iOS.

      Steps to Reproduce

      1. Run the sample code below and click on different annotations. The ones near to the border have annotations cut-off. Running the same code on iOS shift the mapview so the annotations are clearly visible.

       
      var win = Ti.UI.createWindow({
          backgroundColor : 'white'
      });
       
      win.open();
       
      var mapObject = Titanium.Map.createView({
          mapType : Titanium.Map.STANDARD_TYPE,
          animate : true,
          regionFit : true,
          userLocation : true,
          height : '150dp',
          zoomEnabled : true,
          region : {
              latitude : 37.77501,
              longitude : -122.419,
              latitudeDelta : 0.01,
              longitudeDelta : 0.01
          },
      });
       
      var selectAnnotations = Ti.UI.createButton({
          title : "Select Annotations",
          bottom : '20dp',
          height : '35dp',
          width : '180dp'
      });
       
      var annotation = Titanium.Map.createAnnotation({
          animate : true,
          title : 'Hello I am an annotation with lots of information:',
          subtitle : 'This is a subtitle to an large annotation',
          pincolor : Titanium.Map.ANNOTATION_RED,
          latitude : parseFloat(37.776),
          longitude : parseFloat(-122.419)
      });
       
      var annotation2 = Titanium.Map.createAnnotation({
          animate : true,
          title : '#2 Hello I am an annotation with lots of information:',
          subtitle : 'This is a subtitle to an large annotation',
          pincolor : Titanium.Map.ANNOTATION_RED,
          latitude : parseFloat(37.77501),
          longitude : parseFloat(-122.419)
      });
       
      var annotation3 = Titanium.Map.createAnnotation({
          animate : true,
          title : '#3 Hello I am an annotation with lots of information:',
          subtitle : 'This is a subtitle to an large annotation',
          pincolor : Titanium.Map.ANNOTATION_RED,
          latitude : parseFloat(37.770),
          longitude : parseFloat(-122.419)
      });
       
      var annotation4 = Titanium.Map.createAnnotation({
          animate : true,
          title : '#4 Hello I am an annotation with lots of information:',
          subtitle : 'This is a subtitle to an large annotation',
          pincolor : Titanium.Map.ANNOTATION_RED,
          latitude : parseFloat(37.770),
          longitude : parseFloat(-122.43)
      });
       
      mapObject.addAnnotation(annotation);
      mapObject.addAnnotation(annotation2);
      mapObject.addAnnotation(annotation3);
      mapObject.addAnnotation(annotation4);
       
      win.add(mapObject);
      win.add(selectAnnotations);
       
       
      selectAnnotations.addEventListener('click', function(e) {
          mapObject.selectAnnotation(annotation2);
       
      });
      
      

        Attachments

          Activity

            People

            • Assignee:
              pwang Ping Wang
              Reporter:
              vjoshi Varun Joshi
            • Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

                • Titanium SDK/CLI <> Titanium Mobile
                  Synced with:
                  TIMOB-5413
                  Sync status:
                  ERROR
                  Last received:
                  Last sent:

                  Git Source Code