【问题标题】:Reducing load time of offline mbtiles layer in Mapbox Android SDK减少 Mapbox Android SDK 中离线 mbtiles 层的加载时间
【发布时间】:2015-04-29 10:20:37
【问题描述】:

我有一个基本的 Android 应用程序,它使用 Mapbox SDK(版本 0.7.3)加载并显示本地 .mbtiles 文件,但在加载瓷砖。看起来它可能正在加载所有图块(不仅仅是启动时可见的图块)。有没有办法改变这一点。 .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

【问题讨论】:

    标签: android mapbox mbtiles


    【解决方案1】:

    您的代码中比较慢的部分是 MBTilesLayer 的创建。其他一切都应该顺利。因此,您可以做的一件事是将缓慢的 new MBTilesLayer(this, "DK_underlay_1_0_4.mbtiles") 代码移动到 AsyncTask 中,这样您的 UI 在缓慢加载期间不会被阻塞。这不会减少加载时间,但可以确保 UI 不被阻塞。

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-02-04
      • 2017-05-18
      • 2014-10-11
      • 1970-01-01
      • 2011-05-27
      • 2014-05-30
      相关资源
      最近更新 更多