2015-02-24 53 views
1

我正在使用Skobbler SDK 2.3,我想知道如何更新SKMaps.zip中的地图样式。Android:如何更新Skobbler地图样式

问题:

我修改了含“daystyle”,但我注意到,这个只需要删除的应用程序数据后生效。这真的不是我想要的。它看起来像SKPrepareMapTextureThread(android.content.Context context, java.lang.String mapTexturesPath,java.lang.String zipName, SKPrepareMapTextureListener listener).start()
只复制文件如果SKMaps文件夹不存在。有人知道在start()方法中是否有这样的检查,或者(更好)如何将修改后的SKMap样式提供给用户?

+0

取代旧的风格,我们我们正在研究它 - 我们将回到开发团队的答案 – SylviA 2015-02-27 09:52:46

回答

1

如果SKMaps文件夹不存在,并且这是它的打算方式,SKPrepareMapTextureThread只会复制文件,因为地图资源的解压缩需要相当长的时间,并且只能执行一次。 要更新样式,将需要一个解决方法:

1)从映射资源路径中删除文件.installed.txt并调用SKPrepareMapTextureThread,以便资源从资产中恢复。虽然这是最简单的方法,它也是最消耗时间:

​​

2)更优化的方法是编写一个程序,随着新一个

copyFile(new File("path/daystyle.json"), new File("mapResourcesDirPath/SKMaps/daystyle/daystyle.json")); 
... 
public static void copyFile(File sourceFile, File destFile) throws IOException { 
    if(!destFile.exists()) { 
     destFile.createNewFile(); 
    } 

    FileChannel source = null; 
    FileChannel destination = null; 
    try { 
     source = new FileInputStream(sourceFile).getChannel(); 
     destination = new FileOutputStream(destFile).getChannel(); 

     // previous code: destination.transferFrom(source, 0, source.size()); 
     // to avoid infinite loops, should be: 
     long count = 0; 
     long size = source.size(); 
     while((count += destination.transferFrom(source, count, size-count))<size); 
    } 
    finally { 
     if(source != null) { 
      source.close(); 
     } 
     if(destination != null) { 
      destination.close(); 
     } 
    } 
}