我正在使用Skobbler SDK 2.3.0,针对Lollipop,在基于Android Studio 1.0.2构建的Nexus 5和Galaxy S4上进行测试。
我有一个带导航抽屉和片段的MainActivity。我在MainActivity中初始化Skobbler并加载显示地图的片段。但是,我只得到一个黑屏,右下角有“Powered by Scout OSM”的水印。单注和双击是注册的,但如果我捏缩放应用程序崩溃。
在应用崩溃之前,我没有在logcat中看到任何错误。有人可以帮忙吗?
项目结构:
build.grade:
dependencies {
...
...
compile files('libs/SKMaps.jar')
}
logcat的
01-05 22:58:42.835 26785-26785/com.example.android I/MainActivity﹕ onCreate
01-05 22:58:42.869 26785-26785/com.example.android I/System.out﹕ Item selected in navigation drawer
01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Adding login fragment
01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Done
01-05 22:58:42.895 26785-26785/com.example.android I/MainActivity﹕ Initialising Skobbler
01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ Start initializeLibrary()
01-05 22:58:42.899 26785-26785/com.example.android D/SKMaps﹕ SKMapInitSettings---- Map style [/storage/emulated/0/Android/data/com.example.android/files/SKMaps/daystyle/ , daystyle.json ,-1]
01-05 22:58:42.899 26785-26785/com.example.android D/SKMaps﹕ SKVersionManager----setMapUpdateListener - com.example.android.MainActivity@1c8a98bc
01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ End initializeLibrary()
01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ Skobbler initialised
01-05 22:58:42.899 26785-26785/com.example.android I/MainActivity﹕ onCreate end
...
01-05 22:58:55.790 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----SKMapSurfaceView constructor
01-05 22:58:55.790 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----os model Nexus 5
01-05 22:58:55.797 26785-26785/com.example.android D/SKMaps﹕ MapRenderer----Set map density 3.0
01-05 22:58:55.800 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView---- ON PAUSE
01-05 22:58:55.803 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView----Saved map cache state [ Map Region zoom=17.0 center= [13.385000228881836,52.51665115356445]] [Display mode=MODE_2D] [Follower mode=NONE] [Compass shown=false Position = [0.0 ,0.0] ] [Rotation=true ] [Panning=true][Zooming=true] [Bearing=0.0] [Annotations=0]
01-05 22:58:55.811 26785-26785/com.example.android E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: null/res/xhdpi/icon_map_popup_navigate.png: open failed: ENOENT (No such file or directory)
01-05 22:58:55.813 26785-26785/com.example.android E/BitmapFactory﹕ Unable to decode stream: java.io.FileNotFoundException: null/res/xhdpi/icon_map_popup_arrow.png: open failed: ENOENT (No such file or directory)
01-05 22:58:55.822 26785-26785/com.example.android D/SKMaps﹕ SKMapSurfaceView---- centerMapOnPosition [19.8171,41.3294]
答案 0 :(得分:9)
初始化地图后,您缺少一条语句:
mapView.onResume();
如果您查看Skobbler中的示例,您会看到他们将纹理复制到一个Activity
中,并将地图显示在另一个中。显示地图的Activity
会在mapView.onResume()
回调中调用mapView.onPause()
和Activity
。如果要加载纹理并在同一Activity
中显示地图,则必须在复制资源并初始化地图后调用mapView.onResume()
。