Gmap.Net不能预取图块

时间:2018-10-19 13:13:35

标签: c# gmap.net

我正在尝试在应用程序中使用Gmap.net,并且正在尝试预提取图块,以便以后在离线状态下使用。

我的示例代码是:

 private void MapView_Loaded(object sender, RoutedEventArgs e)
    {
        MapView.CacheLocation = AppDomain.CurrentDomain.BaseDirectory + @"\MapCache";

        GMap.NET.GMaps.Instance.Mode = GMap.NET.AccessMode.ServerAndCache;
        //Chosing provider. OpenStreetMap provider is the only free one in commercial projects.

        MapView.MapProvider = GMap.NET.MapProviders.OpenStreetMapProvider.Instance;





        //Clear cache
        //GMap.NET.GMaps.Instance.OptimizeMapDb(null);


        MapView.MinZoom = 2;
        MapView.MaxZoom = 17;
        //// whole world zoom
        MapView.Zoom = 2;
        //// lets the map use the mousewheel to zoom
        MapView.MouseWheelZoomType = GMap.NET.MouseWheelZoomType.MousePositionAndCenter;
        //// lets the user drag the map
        MapView.CanDragMap = true;
        //// lets the user drag the map with the left mouse button
        MapView.DragButton = MouseButton.Left;



    }

 private void Button_Click(object sender, RoutedEventArgs e)
    {
        GMap.NET.RectLatLng area = MapView.SelectedArea;

        if (!area.IsEmpty)
        {
            for (int i = (int)MapView.Zoom; i <= MapView.MaxZoom; i++)
            {

                TilePrefetcher obj = new TilePrefetcher();
                obj.Title = "Prefetching Tiles";
                obj.Icon = this.Icon;
                obj.Owner = this;
                obj.ShowCompleteMessage = false;
                obj.Start(area, i, MapView.MapProvider, 100);

            }

            DialogResult = true;
            Close();
        }
        else
        {
            MessageBox.Show("No Area Chosen", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
        }
    }

问题是当我查看Data.gmdb文件时,它的大小始终为32.928mb。我预取时,在控制台中可以看到“ SQLite错误(5):数据库已锁定”错误消息。

即使我删除文件,它也会自动创建32.928mb大小的文件。

怎么了?

0 个答案:

没有答案