Actual behavior
Adding a view object to a rightview or leftview property on an annotation, crash the app
Expected behavior
Adding a view object to a rightview or leftview and when the annotation gets touched, show the info with the view as on iOS
Steps to reproduce the issue
1. Push the annotation button
2. Click on the annotation
3. Crash
Code
//Android Annotation rightView Bug Android Isolation
var win = Ti.UI.createWindow({
title : 'Annotations'
});
var backButton= Ti.UI.createButton({
title : 'Add Annotation',
bottom : '5dp',
color : 'black',
width : '150',
height : '60',
bottom:'50'
});
var myMap = Titanium.Map.createView({
mapType : Titanium.Map.STANDARD_TYPE,
region : {latitude: 37, longitude: -97,
latitueDelta: 10, longitudeDelta: 10},
animate : true,
regionFit : true,
userLocation : false,
});
win.add(myMap);
win.add(backButton);
backButton.addEventListener('click', function(){
var view1 = Ti.UI.createView({
width : 'auto'
});
var myLbl = Ti.UI.createLabel({
text : 'Status: In Service' + '\n' +
'Truck Type: Flat Bed' + '\n' +
'Speed: 40mph E',
height : 'auto',
width : 'auto',
color : 'white',
font : {fontSize : '9dp'}
});
view1.add(myLbl);
var myAnnotation = Ti.Map.createAnnotation({
latitude : 37.422502,
longitude : -122.08554998,
title : 'Google HQ ',
subtitle : 'sdfsda',
animate : true,
pincolor : Ti.Map.ANNOTATION_RED,
rightView:view1
});
//myAnnotation.rightView = view1;
myMap.addAnnotation(myAnnotation);
});
win.open();
D/AndroidRuntime( 599): Shutting down VM
W/dalvikvm( 599): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/TiApplication( 599): (main) [6845,6845] Sending event: exception on thread: main msg:java.lang.NullPointerException; Titanium 1.9.0,2012/01/18 11:01,1e434e2
E/TiApplication( 599): java.lang.NullPointerException
E/TiApplication( 599): at ti.modules.titanium.map.TiOverlayItemView.setItem(TiOverlayItemView.java:189)
E/TiApplication( 599): at ti.modules.titanium.map.TiMapView.showAnnotation(TiMapView.java:476)
E/TiApplication( 599): at ti.modules.titanium.map.TiMapView.onTap(TiMapView.java:512)
E/TiApplication( 599): at ti.modules.titanium.map.TiMapView$TitaniumOverlay.onTap(TiMapView.java:279)
E/TiApplication( 599): at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
E/TiApplication( 599): at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
E/TiApplication( 599): at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:356)
E/TiApplication( 599): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
E/TiApplication( 599): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
E/TiApplication( 599): at android.view.View.dispatchTouchEvent(View.java:3885)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
E/TiApplication( 599): at ti.modules.titanium.map.TiMapView$LocalMapView.dispatchTouchEvent(TiMapView.java:126)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/TiApplication( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/TiApplication( 599): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
E/TiApplication( 599): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
E/TiApplication( 599): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
E/TiApplication( 599): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
E/TiApplication( 599): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
E/TiApplication( 599): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
E/TiApplication( 599): at android.os.Handler.dispatchMessage(Handler.java:99)
E/TiApplication( 599): at android.os.Looper.loop(Looper.java:130)
E/TiApplication( 599): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/TiApplication( 599): at java.lang.reflect.Method.invokeNative(Native Method)
E/TiApplication( 599): at java.lang.reflect.Method.invoke(Method.java:507)
E/TiApplication( 599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/TiApplication( 599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/TiApplication( 599): at dalvik.system.NativeStart.main(Native Method)
E/AndroidRuntime( 599): FATAL EXCEPTION: main
E/AndroidRuntime( 599): java.lang.NullPointerException
E/AndroidRuntime( 599): at ti.modules.titanium.map.TiOverlayItemView.setItem(TiOverlayItemView.java:189)
E/AndroidRuntime( 599): at ti.modules.titanium.map.TiMapView.showAnnotation(TiMapView.java:476)
E/AndroidRuntime( 599): at ti.modules.titanium.map.TiMapView.onTap(TiMapView.java:512)
E/AndroidRuntime( 599): at ti.modules.titanium.map.TiMapView$TitaniumOverlay.onTap(TiMapView.java:279)
E/AndroidRuntime( 599): at com.google.android.maps.ItemizedOverlay.onTap(ItemizedOverlay.java:453)
E/AndroidRuntime( 599): at com.google.android.maps.OverlayBundle.onTap(OverlayBundle.java:83)
E/AndroidRuntime( 599): at com.google.android.maps.MapView$1.onSingleTapUp(MapView.java:356)
E/AndroidRuntime( 599): at com.google.android.maps.GestureDetector.onTouchEvent(GestureDetector.java:533)
E/AndroidRuntime( 599): at com.google.android.maps.MapView.onTouchEvent(MapView.java:683)
E/AndroidRuntime( 599): at android.view.View.dispatchTouchEvent(View.java:3885)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:903)
E/AndroidRuntime( 599): at ti.modules.titanium.map.TiMapView$LocalMapView.dispatchTouchEvent(TiMapView.java:126)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime( 599): at android.view.ViewGroup.dispatchTouchEvent(ViewGroup.java:942)
E/AndroidRuntime( 599): at com.android.internal.policy.impl.PhoneWindow$DecorView.superDispatchTouchEvent(PhoneWindow.java:1691)
E/AndroidRuntime( 599): at com.android.internal.policy.impl.PhoneWindow.superDispatchTouchEvent(PhoneWindow.java:1125)
E/AndroidRuntime( 599): at android.app.Activity.dispatchTouchEvent(Activity.java:2096)
E/AndroidRuntime( 599): at com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchTouchEvent(PhoneWindow.java:1675)
E/AndroidRuntime( 599): at android.view.ViewRoot.deliverPointerEvent(ViewRoot.java:2194)
E/AndroidRuntime( 599): at android.view.ViewRoot.handleMessage(ViewRoot.java:1878)
E/AndroidRuntime( 599): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime( 599): at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime( 599): at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime( 599): at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime( 599): at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime( 599): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime( 599): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime( 599): at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager( 62): Force finishing activity com.appcelerator.app919927/.App919927Activity
D/dalvikvm( 62): GC_EXTERNAL_ALLOC freed 104K, 41% free 4953K/8327K, external 2088K/2088K, paused 92ms
W/ActivityManager( 62): Activity pause timeout for HistoryRecord{406e7b50 com.appcelerator.app919927/.App919927Activity}
D/dalvikvm( 394): GC_EXPLICIT freed 5K, 51% free 2718K/5511K, external 716K/1038K, paused 49ms
W/ActivityManager( 62): Activity destroy timeout for HistoryRecord{406e7b50 com.appcelerator.app919927/.App919927Activity}
I have the same problem, do you know the solution?
The solution for me is {quote} mapview.removeAnnotation(index_of_annotation); {quote}
Victor, Issue here is not removing annotations, it's adding a rightView to annotation. In android if you do that it will crash the app once you click on the annotation rightView. I do not have workaround for this, still waiting for it to be resolved by appcelerator.
Try to put only left view, with one view that contains all elements.
Tested with 2.0.0.v20120319003254 rhino/v8 with Emulator 2.3.3 and iPhone Simulator 5.0
Reopening to update labels