{ "id": "117903", "key": "TIMOB-14761", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "10153", "key": "TIMOB", "name": "Titanium SDK/CLI", "projectCategory": { "id": "10100", "description": "Titanium and related SDKs used in application development", "name": "Client" } }, "fixVersions": [ { "id": "15646", "description": "2013 Sprint 18", "name": "2013 Sprint 18", "archived": true, "released": true, "releaseDate": "2013-09-06" }, { "id": "15690", "description": "2013 Sprint 18 API", "name": "2013 Sprint 18 API", "archived": true, "released": true, "releaseDate": "2013-09-06" }, { "id": "14982", "description": "Release 3.2.0", "name": "Release 3.2.0", "archived": false, "released": true, "releaseDate": "2013-12-19" } ], "resolution": { "id": "1", "description": "A fix for this issue is checked into the tree and tested.", "name": "Fixed" }, "resolutiondate": "2013-09-04T21:36:23.000+0000", "created": "2013-08-01T23:53:57.000+0000", "priority": { "name": "High", "id": "2" }, "labels": [ "android", "mapv2", "parity" ], "versions": [], "issuelinks": [ { "id": "30648", "type": { "id": "10002", "name": "Duplicate", "inward": "is duplicated by", "outward": "duplicates" }, "inwardIssue": { "id": "118019", "key": "TIMOB-14766", "fields": { "summary": "Android:Not able to access the annotations on map view in Alloy.", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "priority": { "name": "Low", "id": "4" }, "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false } } } } ], "assignee": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "updated": "2013-11-14T09:46:06.000+0000", "status": { "description": "The issue is considered finished, the resolution is correct. Issues which are closed can be reopened.", "name": "Closed", "id": "6", "statusCategory": { "id": 3, "key": "done", "colorName": "green", "name": "Done" } }, "components": [ { "id": "10202", "name": "Android", "description": "Android Platform" } ], "description": "h6.Problem\r\nWhen I attempt to access annotations on a map view created by Ti.Map in Alloy I find that the annotations are undefined, however they are displayed on the map. I do not have this issue when creating the map using the traditional method.\r\n\r\nI need to be able to get all the current annotations and loop through them, I have tried using the getAnnotations() method but no results are returned.\r\n\r\nThis issue does not exist with the map on iOS.\r\n\r\nBelow is the code to reproduce this issue.\r\n\r\nh6.alloy.js\r\n{code:title=alloy.js|borderStyle=solid}\r\nAlloy.Globals.Map = require('ti.map');\r\n{code}\r\n\r\nh6.index.xml\r\n{code:title=index.xml|borderStyle=solid}\r\n\r\n \r\n \r\n \r\n \r\n\r\n{code}\r\n\r\nh6.index.js\r\n{code:title=index.js|borderStyle=solid}\r\nfunction report(evt) {\r\n Ti.API.info(\"Annotation \" + evt.title + \" clicked, id: \" + evt.annotation.myid);\r\n}\r\n\r\n// API calls to the map module need to use the Alloy.Globals.Map reference\r\nvar mountainView = Alloy.Globals.Map.createAnnotation({\r\n latitude:37.390749,\r\n longitude:-122.081651,\r\n title:\"Appcelerator Headquarters\",\r\n subtitle:'Mountain View, CA',\r\n pincolor:Alloy.Globals.Map.ANNOTATION_RED,\r\n myid:1 // Custom property to uniquely identify this annotation.\r\n});\r\n\r\n$.mapview.region = {latitude:33.74511, longitude:-84.38993,\r\n latitudeDelta:0.01, longitudeDelta:0.01};\r\n$.mapview.addAnnotations([mountainView]);\r\n\r\nalert($.mapview.getAnnotations().length);\r\n{code}", "attachment": [], "flagged": false, "summary": "Android: Ti.Map is unable to access getAnnotations() method", "creator": { "name": "g0ld2k", "key": "g0ld2k", "displayName": "Chris Golding", "active": true, "timeZone": "America/New_York" }, "subtasks": [], "reporter": { "name": "g0ld2k", "key": "g0ld2k", "displayName": "Chris Golding", "active": true, "timeZone": "America/New_York" }, "environment": "Android 2.3.5\r\nTitanium 3.1.0 & 3.1.1.GA", "comment": { "comments": [ { "id": "264974", "author": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "body": "h6.Alloy app\nSurprisingly I couldn't use the Alloy global namespace (got a module not found error). Then reproduced the getAnnotations() issue on TiSDK 3.1.1.GA using controller shown below:\n\n{code}\n\n \n \n \n \n\n{code}\n\niOS reports \"1\" meanwhile Android returns \"0\".\n\nh6.Titanium app\nOn TiSDK 3.1.1.GA on iOS Simulator v6.1.2 returns \"1\" annotations, meanwhile Android just returns \"0\" annotations.\n\nIf same method is tested by a Titanium simple sample length property is undefined.\n\nh6.Device stack trace (Razr 2.3.5)\n{code}\n08-05 15:22:19.579: E/TiExceptionHandler(12312): (main) [122,268] ----- Titanium Javascript Runtime Error -----\n08-05 15:22:19.579: E/TiExceptionHandler(12312): (main) [0,268] - In app.js:20,31\n08-05 15:22:19.579: E/TiExceptionHandler(12312): (main) [1,269] - Message: Uncaught TypeError: Cannot read property 'length' of undefined\n08-05 15:22:19.579: E/TiExceptionHandler(12312): (main) [0,269] - Source: alert(mapview.getAnnotations().length);\n{code}\n\nh6.Simple sample\n{code}\nvar win1 = Ti.UI.createWindow();\n\nvar mapview = Ti.Map.createView();\n\n// API calls to the map module need to use the Alloy.Globals.Map reference\nvar mountainView = Ti.Map.createAnnotation({\n\tlatitude : 37.390749,\n\tlongitude : -122.081651,\n\ttitle : \"Appcelerator Headquarters\",\n\tsubtitle : 'Mountain View, CA',\n\tpincolor : Ti.Map.ANNOTATION_RED,\n\tmyid : 1 // Custom property to uniquely identify this annotation.\n});\n\nmapview.region = {\n\tlatitude : 33.74511,\n\tlongitude : -84.38993,\n\tlatitudeDelta : 0.01,\n\tlongitudeDelta : 0.01\n};\n\nmapview.addAnnotations([mountainView]);\n\nalert(mapview.getAnnotations().length);\nwin1.add(mapview);\n\nwin1.open(); \n{code}", "updateAuthor": { "name": "egomez", "key": "egomez", "displayName": "Eduardo Gomez", "active": false, "timeZone": "America/Los_Angeles" }, "created": "2013-08-05T20:29:47.000+0000", "updated": "2013-08-05T20:29:47.000+0000" }, { "id": "264984", "author": { "name": "g0ld2k", "key": "g0ld2k", "displayName": "Chris Golding", "active": true, "timeZone": "America/New_York" }, "body": "I did find a method to get the annotations on Android. However you have to create the annotations prior to creating the view, and any annotations added after creating the view are not returned by getAnnotations(). This doesn't solve my issue since I am creating and deleting annotations on the fly.\r\n\r\n{code}\r\nvar MapModule = require('ti.map');\r\n \r\nvar win = Ti.UI.createWindow({fullscreen: false, layout: \"vertical\"});\r\n\r\n \r\nvar anno = MapModule.createAnnotation({\r\n latitude : -33.87365,\r\n longitude : 151.20689,\r\n title : \"Drag Me\",\r\n subtitle : \"Sydney is quite chill\",\r\n draggable : true\r\n});\r\nvar anno2 = MapModule.createAnnotation({\r\n latitude : -33.86365,\r\n image : \"applogo.png\",\r\n longitude : 151.21689,\r\n title : \"Drag Me 2\",\r\n subtitle : \"This is anno2\",\r\n draggable : true\r\n});\r\nvar anno3 = MapModule.createAnnotation({\r\n latitude : -33.85365,\r\n pincolor : MapModule.ANNOTATION_BLUE,\r\n longitude : 151.20689,\r\n title : \"anno3\",\r\n subtitle : \"This is anno3\",\r\n draggable : false\r\n});\r\n \r\nvar map = MapModule.createView({\r\n enableZoomControls: false,\r\n mapType: MapModule.NORMAL_TYPE,\r\n animate: true,\r\n annotations: [anno, anno2, anno3],\r\n region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 } //Sydney\r\n});\r\n \r\nvar anno4 = MapModule.createAnnotation({\r\n latitude : -34.85365,\r\n pincolor : MapModule.ANNOTATION_BLUE,\r\n longitude : 152.20689,\r\n title : \"anno4\",\r\n subtitle : \"This is anno4\",\r\n draggable : false\r\n});\r\n\r\nmap.addAnnotation(anno4);\r\n\r\nwin.add(map);\r\nwin.open();\r\n\r\nalert(map.getAnnotations().length);\r\n{code}", "updateAuthor": { "name": "g0ld2k", "key": "g0ld2k", "displayName": "Chris Golding", "active": true, "timeZone": "America/New_York" }, "created": "2013-08-05T20:55:30.000+0000", "updated": "2013-08-05T20:55:30.000+0000" }, { "id": "268012", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "master PR: https://github.com/appcelerator-modules/ti.map/pull/3\n", "updateAuthor": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-23T23:32:23.000+0000", "updated": "2013-08-23T23:32:23.000+0000" }, { "id": "268019", "author": { "name": "hpham", "key": "hpham", "displayName": "Hieu Pham", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Testing steps: \r\n\r\n1. Run the classic titanium test case mentioned in the above comment. Should see an alert showing '4'.\r\n2. Run app.js from example/app.js inside the map module. Play around with 'Annotation Test' suite and make sure there are no regressions.\r\n3. Run this additional test case\r\n{code}\r\nvar MapModule = require('ti.map');\r\n \r\nvar win = Ti.UI.createWindow({fullscreen: false, layout: \"vertical\"});\r\n \r\n \r\nvar anno = MapModule.createAnnotation({\r\n latitude : -33.87365,\r\n longitude : 151.20689,\r\n title : \"anno\",\r\n subtitle : \"Sydney is quite chill\",\r\n draggable : true\r\n});\r\nvar anno2 = MapModule.createAnnotation({\r\n latitude : -33.86365,\r\n image : \"applogo.png\",\r\n longitude : 151.21689,\r\n title : \"anno2\",\r\n subtitle : \"This is anno2\",\r\n draggable : true\r\n});\r\nvar anno3 = MapModule.createAnnotation({\r\n latitude : -33.85365,\r\n pincolor : MapModule.ANNOTATION_BLUE,\r\n longitude : 151.20689,\r\n title : \"anno3\",\r\n subtitle : \"This is anno3\",\r\n draggable : false\r\n});\r\n \r\nvar map = MapModule.createView({\r\n enableZoomControls: false,\r\n mapType: MapModule.NORMAL_TYPE,\r\n animate: true,\r\n //annotations: [anno, anno2, anno3],\r\n region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 } //Sydney\r\n});\r\n \r\nvar anno4 = MapModule.createAnnotation({\r\n latitude : -34.85365,\r\n pincolor : MapModule.ANNOTATION_BLUE,\r\n longitude : 152.20689,\r\n title : \"anno4\",\r\n subtitle : \"This is anno4\",\r\n draggable : false\r\n});\r\n\r\nwin.add(map);\r\nwin.open();\r\n\r\n\r\nsetTimeout (function() {\r\n\r\nmap.addAnnotations([anno, anno2, anno4]);\r\nmap.removeAllAnnotations();\r\nmap.removeAnnotations([\"anno4\"]);\r\nmap.removeAnnotation(anno);\r\nmap.addAnnotations([anno, anno2]);\r\n\r\nTi.API.info(JSON.stringify(map.getAnnotations()));\r\nalert((map.getAnnotations().length));\r\n}, 1000);\r\n{code}\r\nYou should see an alert printing '2', and logcat should have the content of those 2 annotations.\r\n4. Change line 61 in the above code to 100 (instead of 1000), also try to run the block without setTimeout. The result should be the same.\r\n", "updateAuthor": { "name": "pwang", "key": "pwang", "displayName": "Ping Wang", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-08-24T00:01:38.000+0000", "updated": "2013-09-04T21:12:47.000+0000" }, { "id": "279525", "author": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "body": "Verified with test environment:\r\n\r\nAppcelerator Studio: 3.2.0.201311122338\r\nSDK:3.2.0.v20131113183932\r\nalloy: 1.3.0\r\nacs: 1.0.7\r\nnpm: 1.3.2\r\ntitanium: 3.2.0\r\ntitanium-code-processor: 1.1.0\r\nXcode:5.0.2\r\nDevice: Google Nexus7(v4.3)\r\nOS: Mac OSX 10.9\r\n\r\n\r\ngetAnnotation() working fine.", "updateAuthor": { "name": "pagarwal", "key": "pagarwal", "displayName": "Priya Agarwal", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2013-11-14T09:46:06.000+0000", "updated": "2013-11-14T09:46:06.000+0000" } ], "maxResults": 7, "total": 7, "startAt": 0 } } }