Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-14493] iOS: TiMapViewProxy removeAnnotations method does not work as per documentation.

GitHub Issuen/a
TypeBug
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2014-08-19T06:42:56.000+0000
Affected Version/sRelease 2.1.4, Release 3.1.0, Release 3.1.1
Fix Version/s2013 Sprint 15 API, 2013 Sprint 15, Release 3.2.0
ComponentsiOS
LabelsTi.map, Titanium, i0S, mapView, mobilesdk, module_map, qe-manualtest
ReporterAshish Nigam
AssigneeVishal Duggal
Created2013-07-08T11:53:04.000+0000
Updated2014-08-19T06:42:56.000+0000

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.

Comments

  1. Vishal Duggal 2013-07-23

    Pull pending https://github.com/appcelerator/titanium_mobile/pull/4470
  2. Pragya Rastogi 2013-10-25

    Tested & Verified the fix with: OSX: 10.8.5 Xcode:5.0 Appcelerator Studio: 3.2.0.201310250414 SDK: 3.2.0.v20131024120843 acs:1.0.7 alloy:1.2.2 npm:1.3.2 titanium:3.2.0 titanium-code-processo:1.0.3 Device: iPod touch 2 (v iOS7)

JSON Source