{ "id": "102045", "key": "AC-2566", "fields": { "issuetype": { "id": "1", "description": "A problem which impairs or prevents the functions of the product.", "name": "Bug", "subtask": false }, "project": { "id": "12217", "key": "AC", "name": "Appcelerator - INBOX", "projectCategory": { "id": "10000", "description": "", "name": "Customer Service" } }, "resolution": { "id": "7", "description": "", "name": "Invalid" }, "resolutiondate": "2012-11-20T22:20:45.000+0000", "created": "2012-09-26T10:12:37.000+0000", "labels": [ "android", "mapview", "performance", "routes" ], "versions": [], "issuelinks": [], "assignee": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "updated": "2016-03-08T07:41:38.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": "14548", "name": "Titanium SDK & CLI", "description": "Please enter tickets related to the MobileSDK here." } ], "description": "h2. Problem\r\nI'm adding a long route to the MapView with lots of points. On a old 1st gen iPod Touch (ARM11) the calculation of the route takes a while, but after it's rendered on the map everything works fine. On the Android x86 emulator, or Galaxy S and Galaxy S2 devices, after the route is drawn on the map the app becomes unresponsive. You can barely pan and zoom. You get the \"App is not responding message\" and you can choose to wait, so you can see the result of panning or zooming.\r\n\r\nh2. Test case\r\n{code:javascript}\r\nvar win = Ti.UI.createWindow({\r\n\ttitle: 'MapView bug',\r\n\texitOnClose: true,\r\n});\r\n\r\nvar actInd = Ti.UI.createActivityIndicator();\r\n\r\nvar mapView = Ti.Map.createView({\r\n mapType: Ti.Map.STANDARD_TYPE,\r\n region: {\r\n latitude: 52.057541,\r\n longitude: 5.251261,\r\n latitudeDelta: 0.1,\r\n longitudeDelta: 0.1,\r\n\t},\r\n animate: true,\r\n userLocation: false,\r\n regionFit: true,\r\n});\r\n\r\nwin.add(mapView);\r\n\r\nwin.addEventListener('open', function() {\r\n\tactInd.show();\r\n\tvar req = Ti.Network.createHTTPClient();\r\n\t\treq.onload = function() {\r\n\t\t\tvar xml = this.responseXML, \r\n\t\t\t\tpoints = [],\r\n\t\t\t\tstatus = xml.documentElement.getElementsByTagName(\"status\").item(0).text;\r\n\t\t\t\t\r\n\t\t\tif (status == \"OK\") {\r\n\t\t\t\tvar steps = xml.documentElement.getElementsByTagName(\"route\").item(0).getElementsByTagName('leg').item(0).getElementsByTagName(\"step\"), \r\n\t\t\t\t\ttotalSteps = steps.length;\r\n\t\t\t\tfor(var i = 0; i < totalSteps; i++) {\r\n\t\t\t\t\tvar polylineString = steps.item(i).getElementsByTagName(\"polyline\").item(0).getElementsByTagName(\"points\").item(0).text,\r\n\t\t\t\t\t\tdecodedPolyline = decodeLine(polylineString);\r\n\t\t\t\t\tfor (var j = 0; j < decodedPolyline.length; j++) {\r\n\t\t\t\t\t\tif (decodedPolyline[j] != null) {\r\n\t\t\t\t\t\t\tpoints.push({\r\n\t\t\t\t\t\t\t\tlatitude : decodedPolyline[j][0],\r\n\t\t\t\t\t\t\t\tlongitude : decodedPolyline[j][1]\r\n\t\t\t\t\t\t\t});\r\n\t\t\t\t\t\t}\r\n\t\t\t\t\t} \r\n\t\t\t\t}\r\n\t\t\t\tmapView.addRoute({\r\n\t\t\t\t\tname: 'myroute',\r\n\t\t\t\t\twidth: 3,\r\n\t\t\t\t\tcolor: '#f00',\r\n\t\t\t\t\tpoints: points\r\n\t\t\t\t});\r\n\t\t\t\tactInd.hide();\r\n\t\t\t} else {\r\n\t\t\t\talert('decode error');\r\n\t\t\t}\r\n\t\t};\r\n\t\treq.onerror = function(e) {\r\n\t\t\talert('error');\r\n\t\t};\r\n\t\treq.timeout = 10000;\r\n\t\treq.open('GET', \"http://maps.google.com/maps/api/directions/xml?mode=driving&origin=45.7787359,21.2129273&destination=52.0613617,5.2069557&sensor=false\");\r\n\t\treq.send();\r\n});\r\n\r\nwin.open();\r\n\r\nfunction decodeLine(encoded) {\r\n\tvar len = encoded.length;\r\n\tvar index = 0;\r\n\tvar array = [];\r\n\tvar lat = 0;\r\n\tvar lng = 0;\r\n \r\n\twhile (index < len) {\r\n\t\tvar b;\r\n\t\tvar shift = 0;\r\n\t\tvar result = 0;\r\n\t\tdo {\r\n\t\t\tb = encoded.charCodeAt(index++) - 63;\r\n\t\t\tresult |= (b & 0x1f) << shift;\r\n\t\t\tshift += 5;\r\n\t\t} while (b >= 0x20);\r\n\t\tvar dlat = ((result & 1) ? ~(result >> 1) : (result >> 1));\r\n\t\tlat += dlat;\r\n\t\t\r\n\t\tshift = 0;\r\n\t\tresult = 0;\r\n\t\tdo {\r\n\t\t\tb = encoded.charCodeAt(index++) - 63;\r\n\t\t\tresult |= (b & 0x1f) << shift;\r\n\t\t\tshift += 5;\r\n\t\t} while (b >= 0x20);\r\n\t\tvar dlng = ((result & 1) ? ~(result >> 1) : (result >> 1));\r\n\t\tlng += dlng;\r\n\r\n\t\tarray.push([lat * 1e-5, lng * 1e-5]);\r\n\t}\r\n \treturn array;\r\n}\r\n{code} \r\n\r\nh2. Community Discussion\r\n[http://developer.appcelerator.com/question/142490/android-mapview-addroute-is-extremely-slow-for-long-routes]", "attachment": [], "flagged": false, "summary": "Android: MapView - Long route performance issues", "creator": { "name": "lucassp", "key": "lucassp", "displayName": "Lucian Pacurar", "active": true, "timeZone": "Europe/Helsinki" }, "subtasks": [], "reporter": { "name": "lucassp", "key": "lucassp", "displayName": "Lucian Pacurar", "active": true, "timeZone": "Europe/Helsinki" }, "environment": "Titanium SDK version: 2.1.2 (08/24/12 14:46 ed7f777)\r\nJavascript Engine: V8\r\nPlatform & version: Android 4.0.3\r\nDevice Details: Android emulator x86/ARM, Galaxy S, Galaxy S2\r\nHost Operating System: OS X 10.8\r\nTitanium Studio version: 2.1.2.201208301612", "comment": { "comments": [ { "id": "228084", "author": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "body": "I calculated that you are creating a line with 25,115 points. That's a lot of points for Android devices to handle all at once. Your best bet is to use some kind of technique to make sure the path is simplified when zooming out, or draw it to a bitmap. There's some examples in the following links:\r\nhttp://stackoverflow.com/questions/4710098/problem-with-large-number-of-markers-on-the-map/4825908#4825908\r\nhttp://stackoverflow.com/questions/6666723/how-to-make-route-drawing-more-efficient\r\nhttp://stackoverflow.com/questions/11590169/drawing-filtering-100k-points-to-mapview-in-android\r\nI'm closing it for now as I don't believe this is a problem with Titanium. If you think otherwise, I'd be happy to re-open.", "updateAuthor": { "name": "dsefton", "key": "dsefton", "displayName": "Daniel Sefton", "active": true, "timeZone": "America/Los_Angeles" }, "created": "2012-11-20T22:20:45.000+0000", "updated": "2012-11-20T22:20:45.000+0000" }, { "id": "280967", "author": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "body": "Invalid issue. ", "updateAuthor": { "name": "mpmiranda", "key": "mpmiranda", "displayName": "Mauro Parra-Miranda", "active": true, "timeZone": "America/Mexico_City" }, "created": "2013-11-24T22:18:24.000+0000", "updated": "2013-11-24T22:18:24.000+0000" } ], "maxResults": 2, "total": 2, "startAt": 0 } } }