我正在使用 Gmap.net,我已经成功地实现了 mbtile 地图。当系统中的互联网连接可用时,当第一次在“ C:\Users\manish.jain\AppData\Local\GMap.NET ”中创建文件夹 GMap.NET 时,这在机器上工作正常。此时; 有多个文件夹创建如下:
但是,当在离线模式下执行相同的操作时,只有两个文件夹创建在与以下位置相同的位置:
在这种情况下,我在地图的每个图块上都收到了消息
"Exception:Buffer cannot be null. Paremeter name: buffer"
我的要求是始终在离线模式下完成所有地图工作,因为在客户端没有可用的互联网连接。
请让我知道所有这些文件夹的含义和目的以及此问题的解决方案。我在 Map's Mode 中使用了这行代码:
MainMap.Manager.Mode = AccessMode.ServerAndCache;
并从定义的位置加载 mbtile 为:
MainMap = new Demo.WindowsForms.Map();
MainMap.MapProvider = new MBTilesMapProvider(@"C:\\India.mbtiles");
MainMap.MinZoom = MainMap.MapProvider.MinZoom;
MainMap.MaxZoom = MainMap.MapProvider.MaxZoom;
我为这个问题搜索了很多,但在 google 或 stackoverflow 中找不到任何解决方案。请帮忙!
最后,我花了宝贵的 4-5 个小时发现在尝试打开 SQLite 连接时出现问题后,我得到了这个问题的解决方案。我收到了“无法打开数据库文件”的异常。此连接已使用以下行解决,其中 parseViaFramework 需要在创建连接实例时传递,如下所示:
using (SQLiteConnection conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", Path),true))
在 MBTileHelper.cs 类中:
public byte[] GetTileStream(long x, long y, int zoom)
{
byte[] retval = null;
try
{
//using (SQLiteConnection conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", Path)))
using (SQLiteConnection conn = new SQLiteConnection(String.Format("Data Source={0};Version=3;", Path),true))
{
conn.Open(); // Here I was getting an exception.
using (SQLiteCommand cmd = new SQLiteCommand() { Connection = conn, CommandText = String.Format("SELECT * FROM tiles WHERE tile_column = {0} and tile_row = {1} and zoom_level = {2};", x, y, zoom) })
{
SQLiteDataReader reader = cmd.ExecuteReader();
if (reader.Read())
{
byte[] bytes = reader["tile_data"] as byte[];
retval = bytes;
}
}
}
}
catch(Exception ex)
{
retval = null;
}
return retval;
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句