Titanium JIRA Archive
Appcelerator Community (AC)

[AC-2560] [Android] Google Maps API v2 does not work in a scrollableview

GitHub Issuen/a
TypeBug
Priorityn/a
StatusClosed
ResolutionWon't Fix
Resolution Date2013-03-20T19:23:45.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAppcelerator Modules
Labelsandroid, heavyweight, map, scrollableView
ReporterTommy Leung
AssigneeMauro Parra-Miranda
Created2013-03-05T17:11:36.000+0000
Updated2016-03-08T07:41:37.000+0000

Description

Problem

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.

Test case

*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();

Attachments

FileDateSize
mapsv2.zip2013-03-21T17:44:54.000+00001214397
Screen Shot 2013-03-21 at 2.27.22 PM.png2013-03-21T18:47:07.000+000080979

Comments

  1. Carter Lathrop 2013-03-20

    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
  2. Tommy Leung 2013-03-21

    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.
  3. Tommy Leung 2013-03-21

    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.
  4. Tommy Leung 2013-03-21

    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
  5. Tommy Leung 2013-03-21

    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.

JSON Source