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

iOS: TiMapViewProxy removeAnnotations method does not work as per documentation.

    Details

      Description

      In iOS Environment removeAnnotations method documentation says, annotations to be removed should be passed as an array, but the SDK Implementation does not handle that.

      While The SDK implementation is written for the annotation names to be passed directly as a multiple parameter without any array being involved.

      Documentation Link: http://docs.appcelerator.com/titanium/latest/#!/api/Titanium.Map.View-method-removeAnnotations

      SDK Implementation Link:
      https://github.com/appcelerator/titanium_mobile/blob/master/iphone/Classes/TiMapViewProxy.m

      Line Number 310 to 329...

      *Sample code to test*

      var win = Titanium.UI.createWindow();
       
      var mountainView = Titanium.Map.createAnnotation({
          latitude:37.390749,
          longitude:-122.081651,
          title:"Appcelerator Headquarters",
          subtitle:'Mountain View, CA',
          pincolor:Titanium.Map.ANNOTATION_RED,
          animate:true,
          leftButton: '../images/appcelerator_small.png',
          myid:1 // Custom property to uniquely identify this annotation.
      });
       
      var mountainViewAnno = Titanium.Map.createAnnotation({
          latitude:28.390749,
          longitude:-72.081651,
          title:"Custome 1",
          subtitle:'Mountain View 2',
          pincolor:Titanium.Map.ANNOTATION_GREEN,
          animate:true,
          leftButton: '../images/appcelerator_small.png',
          myid:2 // Custom property to uniquely identify this annotation.
      });
       
      var view1 = Ti.UI.createView({
      	top:100,
      	left:10,
      	width:310,
      	height:320,
      	backgroundColor:"gray"
      });
       
      var button = Ti.UI.createButton({
      	top:10,
      	left:50,
      	width:110,
      	height:80,
      	backgroundColor:"gray",
      	title:"Remove Annotations"
      });
      var annoArr = [mountainView,mountainViewAnno];
      var mapview = Titanium.Map.createView({
          mapType: Titanium.Map.STANDARD_TYPE,
          region: {latitude:33.74511, longitude:-84.38993, 
                  latitudeDelta:0.01, longitudeDelta:0.01},
          animate:true,
          regionFit:true,
          userLocation:true,
          annotations:annoArr
      });
       
      view1.add(mapview);
      win.add(view1);
      // Handle click events on any annotations on this map.
      mapview.addEventListener('click', function(evt) {
       
          Ti.API.info("Annotation " + evt.title + " clicked, id: " + evt.annotation.myid);
       
          // Check for all of the possible names that clicksouce
          // can report for the left button/view.
          if (evt.clicksource == 'leftButton' || evt.clicksource == 'leftPane' ||
              evt.clicksource == 'leftView') {
              Ti.API.info("Annotation " + evt.title + ", left button clicked.");
          }
      });
       
      button.addEventListener("click",function(){
      	//mapview.removeAnnotations(mountainView,mountainViewAnno);  // this is working but it should not as per documentation
      	
      	mapview.removeAnnotations(annoArr); // this is not working though it should as per documentation
      });
      win.add(button);
      win.open();
      

      Test Cases:

      1: Use the above code sample, and put it on app.js of new sample project.
      2: Run the sample and once you click remove annotations button, you will see some error and annotations are not removed.
      3: now go to below mentioned code in the sample provided above

      button.addEventListener("click",function(){
      	//mapview.removeAnnotations(mountainView,mountainViewAnno);  // this is working but it should not as per documentation
      	
      	mapview.removeAnnotations(annoArr); // this is not working though it should as per documentation
      });
      

      4: Alternate the comment line and test again.
      5: this time it will work.

      Conclusion: Either documentation is wrong or TiSDK TiMapViewProxy needs to be modified to accomodate documentation use cases.

        Attachments

          Activity

            People

            • Assignee:
              vduggal Vishal Duggal (Inactive)
              Reporter:
              anigam Ashish Nigam
              Reviewer:
              Sabil Rahim
            • Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Backbone Issue Sync

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

                  Git Source Code