1. 程式人生 > >Android百度地圖開發-自定義地圖的使用和坑

Android百度地圖開發-自定義地圖的使用和坑

  • 設定個性化地圖config檔案路徑 */ public static void setMapCustomFile(Context context, String PATH) { FileOutputStream out = null; InputStream inputStream = null; String moduleName = null; try { //“customConfigdir/” + inputStream = context.getAssets() .open(PATH); byte[] b = new byte[inputStream.available()]; inputStream.read(b); moduleName = context.getFilesDir().getAbsolutePath(); File f = new File(moduleName + “/” + PATH); if (f.exists()) { f.delete(); } f.createNewFile(); out = new FileOutputStream(f); out.write(b); } catch (IOException e) { e.printStackTrace(); } finally { try { if (inputStream != null) { inputStream.close(); } if (out != null) { out.close(); } } catch (IOException e) { e.printStackTrace(); } } MapView.setCustomMapStylePath(moduleName + “/” + PATH);