Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-9913] Android: Map:View:'Animate' is also a function as per docs, but app is treating it as a property

GitHub Issuen/a
TypeBug
PriorityLow
StatusClosed
ResolutionFixed
Resolution Date2013-12-02T23:51:10.000+0000
Affected Version/sRelease 2.0.1
Fix Version/s2013 Sprint 25, 2013 Sprint 25 API, Release 3.3.0
ComponentsAndroid
Labelscore, insight, module_map, parity, qe-closed-3.3.0, qe-testadded
ReporterShyam Bhadauria
AssigneeBill Dawson
Created2012-07-10T04:38:59.000+0000
Updated2014-04-28T09:28:14.000+0000

Description

This is not a regression. It exists as far as 1.8.2. Issue - While running the app, it gives error "Property 'animate' of object # is not a function". As per docs, it is also a method. This issue does not comes in iOS. There it works as expected. Steps to reproduce: 1) Use the code below
var win = Ti.UI.createWindow();
     
    var scrollView = Ti.UI.createScrollView({
        contentHeight: 'auto',
        contentWidth: 'auto',
        layout:'vertical', //Change from default value from absolute to a relative distance between the sibling views
        scrollType:"vertical",
        top: 0,
        showVerticalScrollIndicator: true,
        showHorizontalScrollIndicator: false
    }); 
     
    var mapView = Ti.Map.createView({
        mapType: Ti.Map.STANDARD_TYPE,
        height: 150,
        top:0,
        animate:true,
        regionFit:true,
        userLocation:true,
        annotations:[]
    });
     
    var resizeBtn = Ti.UI.createButton({
        title:"resize map",
        width:100,
        height:44,
        right:5,
        bottom:5
    });
    var mapToggle = false;
    resizeBtn.addEventListener("click", function(e){
        mapToggle = !mapToggle;
        if(mapToggle){
            mapView.animate({height:250, duration:300});
        } else {
            mapView.animate({height:150, duration:300});
        }
    });
    mapView.add(resizeBtn);
    scrollView.add(mapView);
     
    //other content
    var testView = Ti.UI.createView({top:0, height:200, width:300, backgroundColor:"red"});
     
    var resize2Btn = Ti.UI.createButton({
        title:"resize view",
        width:120,
        height:44,
        right:5,
        bottom:5
    });
    var toggle = false;
    resize2Btn.addEventListener("click", function(e){
        toggle = !toggle;
        if(toggle){
            testView.animate({height:300, duration:300});
        } else {
            testView.animate({height:200, duration:300});
        }
    });
    testView.add(resize2Btn);
    scrollView.add(testView);
     
    //other content
    scrollView.add(Ti.UI.createView({top:0, height:200, width:300, backgroundColor:"blue"}));
     
    win.add(scrollView);
     
win.open();
2) Click the button 'resize map' Actual result 1) After step 2,a runtime error is shown stating property 'animate' of object # is not a function. Expected result 1) Animate should also be treated as a function (as per docs).

Comments

  1. Bill Dawson 2013-08-19

    TESTING NOTES: * Run this app.js, which is the same as the reporter's app.js except the "animate" property is set conditionally only if iOS. * Click the "Resize Map" button - the map should resize without runtime error.
       var win = Ti.UI.createWindow();
             
           var scrollView = Ti.UI.createScrollView({
               contentHeight: 'auto',
               contentWidth: 'auto',
               layout:'vertical', //Change from default value from absolute to a relative distance between the sibling views
               scrollType:"vertical",
               top: 0,
               showVerticalScrollIndicator: true,
               showHorizontalScrollIndicator: false
           }); 
             
           var mapView = Ti.Map.createView({
               mapType: Ti.Map.STANDARD_TYPE,
               height: 150,
               top:0,        
               regionFit:true,
               userLocation:true,
               annotations:[]
           });
       
           if (Ti.Platform.osname == 'ipad' || Ti.Platform.osname == 'iphone') {
               mapView.animate = true;
           }
             
           var resizeBtn = Ti.UI.createButton({
               title:"resize map",
               width:100,
               height:44,
               right:5,
               bottom:5
           });
           var mapToggle = false;
           resizeBtn.addEventListener("click", function(e){
               mapToggle = !mapToggle;
               if(mapToggle){
                   mapView.animate({height:250, duration:300});
               } else {
                   mapView.animate({height:150, duration:300});
               }
           });
           mapView.add(resizeBtn);
           scrollView.add(mapView);
             
           //other content
           var testView = Ti.UI.createView({top:0, height:200, width:300, backgroundColor:"red"});
             
           var resize2Btn = Ti.UI.createButton({
               title:"resize view",
               width:120,
               height:44,
               right:5,
               bottom:5
           });
           var toggle = false;
           resize2Btn.addEventListener("click", function(e){
               toggle = !toggle;
               if(toggle){
                   testView.animate({height:300, duration:300});
               } else {
                   testView.animate({height:200, duration:300});
               }
           });
           testView.add(resize2Btn);
           scrollView.add(testView);
             
           //other content
           scrollView.add(Ti.UI.createView({top:0, height:200, width:300, backgroundColor:"blue"}));
             
           win.add(scrollView);
             
       win.open();
       
       
  2. Bill Dawson 2013-08-19

    PR ready: https://github.com/appcelerator/titanium_mobile/pull/4582
  3. Pragya Rastogi 2014-04-28

    Verified the fix using: OSX: 10.9.2 Xcode: 5.1.1 Studio - 3.3.0.201404251359 SDK - 3.3.0.v20140425191906 acs-1.0.14 alloy-1.4.0-dev npm-1.3.2 titanium-3.3.0-dev titanium-code-processor-1.1.1-beta1 Device: LG-P970 (4.0.4)

JSON Source