[MOD-2455] Ti.Map: iOS - Calling removeAllAnnotations when using clusters throws error
	
	
| GitHub Issue | n/a | 
| Type | Bug | 
| Priority | Critical | 
| Status | Resolved | 
| Resolution | Fixed | 
| Resolution Date | 2018-09-05T08:45:27.000+0000 | 
| Affected Version/s | n/a | 
| Fix Version/s | Ti.Map iOS 3.1.1 | 
| Components | n/a | 
| Labels | clustering, ios, maps | 
| Reporter | Mike Stancliffe | 
| Assignee | Vijay Singh | 
| Created | 2018-08-20T18:58:11.000+0000 | 
| Updated | 2018-09-05T08:45:27.000+0000 | 
Description
	In the sample app click "add annotations" and then click "remove annotations".  If you remove the 2 types of annotations separately, like I have commented out in the remove function, it seems to work without issue.
error should resemble 
[ERROR] :  Script Error {
[ERROR] :      column = 29;
[ERROR] :      line = 105;
[ERROR] :      message = "Invalid type passed to function";
[ERROR] :      nativeLocation = "-[TiMapViewProxy annotationFromArg:] (TiMapViewProxy.m:163)";
[ERROR] :      nativeReason = "expected: Object, was: MKClusterAnnotation";
[ERROR] :      nativeStack = "3   MapClustering problems    0x00000001089bd379 -[TiProxy throwException:subreason:location:] + 105\n4   MapClustering problems    0x0000000108ba880f -[TiMapViewProxy annotationFromArg:] + 347\n5   MapClustering problems    0x0000000108baaa9a -[TiMapViewProxy removeAllAnnotations:] + 406\n6   CoreFoundation  0x000000011139336c __invoking___ + 140\n7   CoreFoundation  0x0000000111393240 -[NSInvocation invoke] + 320\n8   MapClustering problems    0x00000001088f5cdd -[KrollMethod call:] + 2045\n9   MapClustering problems    0x00000001088f45a1 __KrollCallAsFunction_block_invoke + 49\n10  MapClustering problems    0x00000001089fb4bd TiThreadPerformOnMainThread + 77\n11  MapClustering problems    0x00000001088f424e KrollCallAsFunction + 702\n12  JavaScriptCore  0x000000010988b940 _ZN3JSC16JSCallbackObjectINS_20JSDestructibleObjectEE4callEPNS_9ExecStateE + 512\n13  JavaScriptCore  0x0000000109996cd1 _ZN3JSC5LLInt9setUpCallEPNS_9ExecStateEPNS_11InstructionENS_22CodeSpecializationKindENS_7JSValueEPNS_17LLIntCallLinkInfoE + 577\n14  JavaScriptCore  0x000000010999ff4d llint_entry + 27269\n15  JavaScriptCore  0x00000001099992e0 vmEntryToJavaScript + 304\n16  JavaScriptCore  0x000000010982a1df _ZN3JSC7JITCode7executeEPNS_2VMEPNS_14ProtoCallFrameE + 127\n17  JavaScriptCore  0x00000001097f0871 _ZN3JSC11Interpreter11executeCallEPNS_9ExecStateEPNS_8JSObjectENS_8CallTypeERKNS_8CallDataENS_7JSValueERKNS_7ArgListE + 433\n18  JavaScriptCore  0x00000001094e14d2 _ZN3JSC12profiledCallEPNS_9ExecStateENS_15ProfilingReasonENS_7JSValueENS_8CallTypeERKNS_8CallDataES3_RKNS_7ArgListE + 178\n19  JavaScriptCore  0x00000001098eb29d JSObjectCallAsFunction + 461";
[ERROR] :      sourceURL = "file:///Users/mikestancliffe/Library/Developer/CoreSimulator/Devices/36D76DE8-F88D-40AA-A46E-7D2B8BBD7247/data/Containers/Bundle/Application/4DAF6BFF-CEDD-4439-94A4-DA4293EAD45C/MapClustering%20problems.app/alloy/controllers/index.js";
[ERROR] :      stack = "    at [native code]\n    at remove@file:///Users/mikestancliffe/Library/Developer/CoreSimulator/Devices/36D76DE8-F88D-40AA-A46E-7D2B8BBD7247/data/Containers/Bundle/Application/4DAF6BFF-CEDD-4439-94A4-DA4293EAD45C/MapClustering%20problems.app/alloy/controllers/index.js:105:29)";
[ERROR] :  }
Attachments
| File | Date | Size | 
| index.js | 2018-08-20T18:54:29.000+0000 | 1289 | 
| index.xml | 2018-08-20T18:54:45.000+0000 | 268 | 
 
Hello, I have tested the issue. I was able to reproduce the issue on our end. Removing annotation does cause the issue as described. I will forward this to our engineering. Thanks.
PR - https://github.com/appcelerator-modules/ti.map/pull/246 Test Case -
var win = Ti.UI.createWindow({ backgroundColor: '#fff' }); var mapContainer = Ti.UI.createView({ bottom: 50 }); var addBtn = Ti.UI.createButton({ title: 'Add Annotations', bottom: 0, left: 20 }); var removeBtn = Ti.UI.createButton({ title: 'Remove Annotations', bottom: 0, left: 150 }); var clusters = []; var points = []; var Map = require('ti.map'); var map = Map.createView(); map.addEventListener('clusterstart', cluster); function add(e) { map.removeAnnotations(points); map.removeAnnotations(clusters); clusters = []; points = []; var lat = 29.951318; var long = -90.080998; for(var x = 0; x<200; x++ ){ var point = Map.createAnnotation({ clusterIdentifier: 'a', latitude: parseFloat(lat), longitude: parseFloat(long), title: x, subtitle: lat +' - '+long, index: x, }); points.push(point); console.warn(lat +' - '+long); lat = lat+parseFloat( (Math.random() * .1)); long = long+parseFloat( (Math.random() * .1)); } console.log('ADD ANNOTATIONS'); map.addAnnotations(points); } function remove(){ map.removeAllAnnotations(); // $.map.removeAnnotations(points); // $.map.removeAnnotations(clusters); } function cluster(e) { Ti.API.info('clustering started'); var clusterAnnotation = Map.createAnnotation({ showAsMarker: true, markerText: e.memberAnnotations.length.toString() + '+', }); clusters.push(clusterAnnotation); map.setClusterAnnotation({ annotation: clusterAnnotation, memberAnnotations: e.memberAnnotations }); } addBtn.addEventListener('click', function(e) { add(); }); removeBtn.addEventListener('click', function(e) { remove(); }); mapContainer.add(map); win.add(addBtn); win.add(removeBtn); win.add(mapContainer); win.open();[~cliff_stander] Can you please verify with https://github.com/appcelerator-modules/ti.map/releases (iOS-3.1.1) .Thanks!