Note that there are some explanatory texts on larger screens.

plurals
  1. POProblem with draw() on a MapView ItemizedOverlay
    text
    copied!<p>I am developing an application for the Parisian Metro. One of the functions is a map where you can click the metro stations and see what are the metro lines, and when are the next 4 trains on this station.</p> <p>I have hence created a <code>MapActivity</code> and an <code>ItemizedOverlay</code> classes.</p> <p>On my device it is working perfectly, but I am getting some logs from the users with a crash, and I really don't understand what's wrong.</p> <p>My map activity adds ONE <code>ItemizedOverlay</code> that displays a blue dot for the current user location. This overlay also listens to onTap, which depending on the coordinates of the tap, will try to find metro stations (for which I know the lat/lon coordinates). This is working perfectly.</p> <p>The stack trace of the crash is:</p> <pre><code>java.lang.NullPointerException at com.google.android.maps.OverlayBundle.draw(OverlayBundle.java:42) at com.google.android.maps.MapView.onDraw(MapView.java:494) at android.view.View.draw(View.java:6535) at android.view.ViewGroup.drawChild(ViewGroup.java:1531) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.ViewGroup.drawChild(ViewGroup.java:1529) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.View.draw(View.java:6538) at android.widget.FrameLayout.draw(FrameLayout.java:352) at android.view.ViewGroup.drawChild(ViewGroup.java:1531) at android.view.ViewGroup.dispatchDraw(ViewGroup.java:1258) at android.view.View.draw(View.java:6538) at android.widget.FrameLayout.draw(FrameLayout.java:352) at com.android.internal.policy.impl.PhoneWindow$DecorView.draw(PhoneWindow.java:1830) at android.view.ViewRoot.draw(ViewRoot.java:1349) at android.view.ViewRoot.performTraversals(ViewRoot.java:1114) at android.view.ViewRoot.handleMessage(ViewRoot.java:1633) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:123) at android.app.ActivityThread.main(ActivityThread.java:4363) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:521) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626) at dalvik.system.NativeStart.main(Native Method) </code></pre> <p>Sometimes it comes from different lines but it always finishes crashing at <code>OverlayBunde.java:42</code></p> <p>As is does not mention my code, I don't know what's wrong.</p> <p>You can get the source code of the <code>MapActivity</code> and the the <code>ItemizedOverlay</code>: <a href="http://code.google.com/p/metroparis/source/browse/trunk/src/org/bicou/metro/" rel="nofollow noreferrer">http://code.google.com/p/metroparis/source/browse/trunk/src/org/bicou/metro/</a></p> <p>The activity class is <code>ACarteStations</code> and the overlay class is <code>StationMetroMapOverlay</code>.</p> <p>I am sorry that the code is in French. I will translate it eventually :) If you need translations about the variable names, just let me know.</p> <p>Hope you can help me!!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload