When a window is heavyweight and the mapview is in a scrollableview. It causes a crash. Also, scrolling to the 2nd view (which is suppose to be red) has traces of the mapview overlayed on top.
*Comment out the navBarHidden and windowSoftInputMode and the app will work again*
var MapModule = require('ti.map');
var win = Ti.UI.createWindow({
backgroundColor: 'white',
navBarHidden: true,
orientationModes: [Ti.UI.PORTRAIT, Ti.UI.UPSIDE_PORTRAIT],
//windowSoftInputMode: Ti.UI.Android.SOFT_INPUT_ADJUST_PAN
});
var scrollableView = Ti.UI.createScrollableView({});
var vert = Ti.UI.createScrollView({
contentHeight: 'auto',
scrollType: 'vertical',
showVerticalScrollIndicator: true,
layout:'vertical',
canCancelEvents: true,
width: Ti.UI.SIZE,
backgroundColor: 'transparent'
});
var opera = MapModule.createAnnotation({
latitude: -33.8569,
longitude: 151.2153,
image: 'SydneyOperaHouse.jpg',
title: 'Sydney Opera House',
subtitle: 'Sydney, New South Wales, Australia'
});
var bridge = MapModule.createAnnotation({
latitude: -33.852222,
longitude: 151.210556,
pincolor: MapModule.ANNOTATION_AZURE,
title: 'Sydney Harbour Bridge',
subtitle: 'Port Jackson'
});
var random = MapModule.createAnnotation({
latitude: -33.87365,
longitude: 151.20689,
pincolor: MapModule.ANNOTATION_VIOLET,
title: 'Random annotation',
subtitle: 'Look at me!',
draggable: true
});
var mapview = MapModule.createView({
top: 200, height: 600,
mapType: MapModule.NORMAL_TYPE,
region: {latitude: -33.87365, longitude: 151.20689, latitudeDelta: 0.1, longitudeDelta: 0.1 },
annotations: [bridge,opera] //< add these annotations upon creation
});
// Add this annotation after creation
mapview.addAnnotation(random);
scrollableView.views = [mapview, Ti.UI.createView({backgroundColor:'red'})]
win.add(scrollableView);
win.open();
Tommy, was this same functionality working on google maps v1? The reason I ask is that the mapview is a type of scrollview and on android it is not suggested or supported (though sometimes works) to have a scrollview within a scrollableview (or scrollview). The android operating system does not support such a nesting of scrollableviews so this is probably why you are seeing the error. This is not a problem with the titanium platform, rather a limitation imposed by the android SDK. Is there a particular reason why you need this functionality or is there any other way to work around this limitation? Regards, Carter
Hi Carter, This functionality does work with google maps v1. The reason we are using this is to support the "scrollable tab" ui introduced with ICS. Since this functionality is not supported in titanium or available in pre-ICS sdks, we must manually create such a ui for the user. The only solution is to have a scrollable view. It just so happens some of the data scrollable view is a map. I do not see why scrollview should not be allowed in a scrollable view. The google play store is a perfect example of using such ui.
I have created and very basic android app with maps in scrollable view (viewpager) and it does not crash or leave behind any artifacts when scrolled. I have attached the sample app. Therefore this is not an Android bug.
A quick research on google seems like this is a issue in native android as well in certain cases, however THERE ARE SOLUTIONS. http://stackoverflow.com/questions/13837697/viewpager-with-google-maps-api-v2-mysterious-black-view
Also attached an image of the lines of code causing the crash. I would hope at least a fix to the crashing is implemented even if some visual fixes cannot be done.