function foo(){ ... GDownloadUrl(entitiesUrl, function(data, responseCode) { if((200==responseCode)&&(0!=data.length)) { try{ var iStart = 0; var arePoints = false; var polylineLevels = ""; //File structure is [encoded Levels
encoded Polylines
...] do { var iEnd = data.indexOf("
",iStart); if( false == arePoints) {//Levels polylineLevels = data.substring(iStart,iEnd); arePoints = true; } else {//Points var polygon = new GPolygon.fromEncoded({ polylines: [{color: "#ffff00", weight: 2, opacity:1.0, points: data.substring(iStart,iEnd), levels: polylineLevels, zoomFactor: 2, numLevels: 18}], fill: true, color:" #ffff00", opacity: 0.3, outline: true}); googleMap.addOverlay(polygon); arePoints = false; } iStart = iEnd + 4;//jump above '
' to the next polylines }while( data.length > iStart) }catch(e){ //here code to deal with errors; } } else { //here code to deal with errors; } }); ... };//end foo()