Osmdroid POI信息窗口崩溃应用

时间:2017-10-11 01:36:56

标签: android osmdroid nominatim

我在尝试点击POI标记时遇到2个错误。

BasicInfoWindow: unable to get res ids in com.JEB.trailmaps

java.lang.NullPointerException:尝试调用虚方法' void android.widget.TextView.setText(java.lang.CharSequence)'在null对象引用上 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.infowindow.BasicInfoWindow.onOpen(BasicInfoWindow.java:86) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.infowindow.MarkerInfoWindow.onOpen(MarkerInfoWindow.java:55) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at com.JEB.trailmaps.MainActivity $ CustomInfoWindow.onOpen(MainActivity.java:1329) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.infowindow.InfoWindow.open(InfoWindow.java:82) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.Marker.showInfoWindow(Marker.java:281) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.Marker.onMarkerClickDefault(Marker.java:438) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.Marker.onSingleTapConfirmed(Marker.java:376) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.DefaultOverlayManager.onSingleTapConfirmed(DefaultOverlayManager.java:230) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.FolderOverlay.onSingleTapConfirmed(FolderOverlay.java:85) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.overlay.DefaultOverlayManager.onSingleTapConfirmed(DefaultOverlayManager.java:230) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at org.osmdroid.views.MapView $ MapViewDoubleClickListener.onSingleTapConfirmed(MapView.java:1381) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at android.view.GestureDetector $ GestureHandler.handleMessage(GestureDetector.java:312) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at android.os.Handler.dispatchMessage(Handler.java:102) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at android.os.Looper.loop(Looper.java:154) 10-10 21:18:03.879 4519 4519 E AndroidRuntime在android.app.ActivityThread.main(ActivityThread.java:6776) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at java.lang.reflect.Method.invoke(Native Method) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:1520) 10-10 21:18:03.879 4519 4519 E AndroidRuntime at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1410)

这是我的POI代码

NominatimPOIProvider poiProvider = new NominatimPOIProvider("com.JEB.trailmaps/1.0");
        ArrayList<POI> pois = poiProvider.getPOIInside(map.getBoundingBox(),myString, 30);
        poiMarkers = new FolderOverlay(MainActivity.this);
        map.getOverlays().add(poiMarkers);
        if(myString.equals("Fuel")){
        poiIcon = getResources().getDrawable(R.drawable.gas);
        }if(myString.equals("Restaurant")){
            poiIcon = getResources().getDrawable(R.drawable.food);
            }
        for (POI poi:pois){
            Marker poiMarker = new Marker(map);
            poiMarker.setTitle(poi.mType);
            poiMarker.setSnippet(poi.mDescription);
            poiMarker.setPosition(poi.mLocation);
            poiMarker.setIcon(poiIcon);

            if (poi.mThumbnail != null){
                poiMarker.setImage(new BitmapDrawable(poi.mThumbnail));
            }
            poiMarker.setInfoWindow(new CustomInfoWindow(map));
            poiMarker.setRelatedObject(poi);
            poiMarkers.add(poiMarker);

我的应用程序中还有其他标记和其他叠加层,所有这些都显示我的信息窗口,就像应该点击一样。我无法弄清楚这是不会发生的事情。我已尝试使用和不使用自定义信息窗口。无论哪种方式我尝试,它崩溃我的应用程序,并给我这些错误。

我也试过设置我的信息窗口,就像我的另一个标记一样,但也没有用。这就是我为所有其他标记设置自定义信息窗口的方法,并对其进行处理。

InfoWindow infoWindow = new MyInfoWindow(R.layout.truck, MainActivity.this.map);
         startMarker.setInfoWindow(infoWindow);

0 个答案:

没有答案