【问题标题】:Saving OSM map tiles in app project在应用程序项目中保存 OSM 地图图块
【发布时间】:2013-07-02 16:13:17
【问题描述】:

只是想知道是否可以将已保存的地图图块从移动地图集中添加到项目而不是 sd 卡?

我希望地图图块在我将发布的应用程序中可用。它是安卓市场上的免费应用程序。

地图图块分为 4 个 zip 文件,是否可以从项目文件中保存和使用它们,或者我需要在线服务器来下载它们。

任何帮助都会很棒

谢谢

【问题讨论】:

    标签: android osmdroid offline-mode


    【解决方案1】:

    一种选择是使用资产文件夹来存储文件,然后将它们复制到您的私有应用数据目录。像这样的东西应该工作。这会复制一个数据库,但您可以调整它以复制您的 zip 文件。

    /**
     * Copies your database from your local assets-folder to the just created empty database in the
     * system folder, from where it can be accessed and handled. This is done by transfering
     * bytestream.
     * */
    private void copyDataBase() throws IOException {
    
        // Open your local db as the input stream
        InputStream myInput = mContext.getAssets().open(DB_NAME);
    
        // Path to the just created empty db
        String outFileName = DB_PATH.toString();
        // boolean success = DB_PATH.mkdirs();
    
        // Open the empty db as the output stream
        OutputStream myOutput = new FileOutputStream(outFileName);
    
        // transfer bytes from the inputfile to the outputfile
        byte[] buffer = new byte[1024];
        int length;
        while ((length = myInput.read(buffer)) > 0) {
            myOutput.write(buffer, 0, length);
        }
    
        // Close the streams
        myOutput.flush();
        myOutput.close();
        myInput.close();
    
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-05-14
      • 1970-01-01
      • 2014-04-13
      相关资源
      最近更新 更多