Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/194.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
减少Mapbox Android SDK中脱机mbtiles层的加载时间_Android_Mapbox_Mbtiles - Fatal编程技术网

减少Mapbox Android SDK中脱机mbtiles层的加载时间

减少Mapbox Android SDK中脱机mbtiles层的加载时间,android,mapbox,mbtiles,Android,Mapbox,Mbtiles,我有一个基本的Android应用程序,它使用Mapbox SDK(版本0.7.3)加载并显示一个本地.mbtiles文件,但是在加载tiles时首次加载应用程序(导致黑屏)时会有很大的延迟。看起来它可能正在加载所有的磁贴(而不仅仅是启动时可见的磁贴)。有没有办法改变这一点。.mbtiles文件大小约为257 MB,启动后应用程序显示地图大约需要40秒 任何帮助都将不胜感激 此处是加载磁贴的位置: protected void onCreate(Bundle savedInstanceState)

我有一个基本的Android应用程序,它使用Mapbox SDK(版本0.7.3)加载并显示一个本地.mbtiles文件,但是在加载tiles时首次加载应用程序(导致黑屏)时会有很大的延迟。看起来它可能正在加载所有的磁贴(而不仅仅是启动时可见的磁贴)。有没有办法改变这一点。.mbtiles文件大小约为257 MB,启动后应用程序显示地图大约需要40秒

任何帮助都将不胜感激

此处是加载磁贴的位置:

protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    this.findViewById(R.id.mapview);

    MapView mapView = (MapView) findViewById(R.id.mapview);
    mapView.setZoom(9);
    mapView.setMinZoomLevel(8);
    mapView.setMaxZoomLevel(15);
    mapView.setCenter(new LatLng(55.676111, 12.568333));
    mapView.setTileSource(new MBTilesLayer(this, "DK_underlay_1_0_4.mbtiles"));

}
以下是加载应用程序时显示约40秒间隔的日志:

04-29 11:07:54.173  23590-23590/com.example.stugrey.testapp D/MapboxMapView﹕ centerLatLng is not specified in XML.
04-29 11:07:54.173  23590-23590/com.example.stugrey.testapp D/Mapbox MapView﹕ zoomLevel is not specified in XML.
04-29 11:08:34.236  23590-23590/com.example.stugrey.testapp D/AppUtils﹕ Device density is 320, and result of @2x check is true
04-29 11:08:34.236  23590-23590/com.example.stugrey.testapp D/MapTileDownloader﹕ Going to use @2x tiles? 'true'
04-29 11:08:34.308  23590-23590/com.example.stugrey.testapp I/Adreno-EGL﹕ <qeglDrvAPI_eglInitialize:410>: EGL 1.4 QUALCOMM build: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1__release_AU ()
OpenGL ES Shader Compiler Version: E031.24.00.08
Build Date: 03/07/14 Fri
Local Branch:
Remote Branch: quic/LNX.LA.3.5.1_RB1.1
Local Patches: NONE
Reconstruct Branch: AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018 + f2fd134 +  NOTHING
04-29 11:07:54.173 23590-23590/com.example.stugray.testapp D/MapboxMapView﹕ 未在XML中指定centerLatLng。
04-29 11:07:54.173 23590-23590/com.example.stugray.testapp D/Mapbox地图视图﹕ 未在XML中指定zoomLevel。
04-29 11:08:34.236 23590-23590/com.example.stugray.testapp D/AppUtils﹕ 设备密度为320,@2x检查结果为真
04-29 11:08:34.236 23590-23590/com.example.stugray.testapp D/MapTileDownloader﹕ 要使用@2x瓷砖吗真的
04-29 11:08:34.308 23590-23590/com.example.stugray.testapp I/Adreno EGL﹕ : EGL 1.4高通公司构建:AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018_msm8226_LNX.LA.3.5.1_RB1_release_AU()
OpenGL ES着色器编译器版本:E031.24.00.08
建造日期:2014年7月3日星期五
本地分行:
远程分支机构:quic/LNX.LA.3.5.1_RB1.1
本地修补程序:无
重构分支:AU_LINUX_ANDROID_LNX.LA.3.5.1_RB1.04.04.02.048.018+f2fd134+NOTHING

代码中缓慢的部分是创建
MBTilesLayer
。其他一切都应该顺利。因此,您可以做的一件事是将慢速
新mbtiles层(这是“DK_underlay_1_0_4.mbtiles”)
代码移动到
异步任务中,以便在慢速加载期间不会阻塞UI。这不会减少加载时间,但可以确保用户界面无阻塞

因此,您可以显示进度指示器(或占位符),而不是黑屏