GoogleMaps MapView crashes onTap in Android?

我是研究僧i 提交于 2019-12-01 05:40:20

mContext is null. Since your overlay is an inner class of the activity, replace mContext with act_map.this in your AlertDialog constructor call.

hasanzuav

I also had a problem with the Android MapView tutorial. When I clicked on the icon, the screen would crash (a null mContext would be passed):

The above fix did not work for me. Instead, I changed the following line of code from the MapActivity class from:

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable);

to this:

HelloItemizedOverlay itemizedoverlay = new HelloItemizedOverlay(drawable, this);

You also need to fix constructor by adding boundCenterBottom which is missing:

public HelloItemizedOverlay(Drawable defaultMarker, Context context) {
    super(boundCenterBottom(defaultMarker));
    mContext = context;
}

(Had beautiful screenshots but can't post because I am new :P)

Hope that helps others who are still having a problem with the tutorial and fixes their apps!

Use this instead, it is a far better tutorial than the one provided by google.

also call populate() in mapoverlay constructor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!