コード例 #1
0
 /// <summary>
 /// 从缓存中加载瓦片
 /// </summary>
 /// <param name="zoom"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="map_mode"></param>
 /// <returns></returns>
 private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode)
 {
     try
     {
         string cache_path = Properties.BMap.Default.MapCachePath;
         if (Directory.Exists(cache_path + "\\" + map_mode.ToString()))
         {
             string cache_name = cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp";
             if (File.Exists(cache_name))
             {
                 return(new Bitmap(cache_name));
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
コード例 #2
0
 /// <summary>
 /// 将从服务器上下载的瓦片保存到缓存
 /// </summary>
 /// <param name="zoom"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="map_mode"></param>
 /// <param name="tile"></param>
 private void SaveTile2Cache(int zoom, int x, int y, MapMode map_mode, Bitmap tile)
 {
     try
     {
         string cache_path = Properties.BMap.Default.MapCachePath;
         if (!Directory.Exists(cache_path + "\\" + map_mode.ToString()))
         {
             Directory.CreateDirectory(cache_path + "\\" + map_mode.ToString());
         }
         tile.Save(cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp");
     }
     catch
     {
     }
 }
コード例 #3
0
 /// <summary>
 /// 从缓存中加载瓦片
 /// </summary>
 /// <param name="zoom"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="map_mode"></param>
 /// <returns></returns>
 private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode)
 {
     try
     {
         string row_Path = Path.Combine(Properties.BMap.Default.MapCachePath, map_mode.ToString(), zoom + "", x + "");
         if (Directory.Exists(row_Path))
         {
             //ZYM-20170818:修改瓦片数据保存格式为png
             string cache_name = Path.Combine(row_Path, zoom + "_" + x + "_" + y + _tile_suffix);
             if (File.Exists(cache_name))
             {
                 return(new Bitmap(cache_name));
             }
             else
             {
                 return(null);
             }
         }
         else
         {
             return(null);
         }
     }
     catch
     {
         return(null);
     }
 }
コード例 #4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="column"></param>
        /// <param name="row"></param>
        /// <param name="zoomLevel"></param>
        /// <returns></returns>
        public override string GetImageUrl(int column, int row, int zoomLevel)
        {
            var code = GetVENumber(column, row, zoomLevel);

            if (MapMode.ToString() == "r")
            {
                return(string.Concat(new object[] { "http://r", code[code.Length - 1], ".ortho.tiles.virtualearth.net/tiles/r", code, ".png?g=1" }));
            }

            return(string.Concat(new object[] { "http://", MapMode.ToString(), code[code.Length - 1], ".ortho.tiles.virtualearth.net/tiles/", MapMode.ToString(), code, ".jpeg?g=1" }));
        }
コード例 #5
0
 /// <summary>
 /// 将从服务器上下载的瓦片保存到缓存
 /// </summary>
 /// <param name="zoom"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="map_mode"></param>
 /// <param name="tile"></param>
 private void SaveTile2Cache(int zoom, int x, int y, MapMode map_mode, Bitmap tile)
 {
     try
     {
         //ZYM-20170818:
         //①将瓦片文件保存目录由原来的所有文件都存储在一个目录下,修改为保存到根目录下的“层级/行号”子目录中;
         //②修改瓦片数据保存格式为png。
         string row_Path = Path.Combine(Properties.BMap.Default.MapCachePath, map_mode.ToString(), zoom + "", x + "");
         if (!Directory.Exists(row_Path))
         {
             Directory.CreateDirectory(row_Path);
         }
         tile.Save(Path.Combine(row_Path, zoom + "_" + x + "_" + y + _tile_suffix));
     }
     catch
     {
     }
 }
コード例 #6
0
        protected virtual string GetJsonDataProperties()
        {
            var mode      = MapMode.ToString().ToLower();
            var key       = GetMapsProviderKey(PageContext.Current);
            var longitude = Rendering.DataSourceItem[Templates.StaticMap.Fields.CentralPointLongitude];
            var latitude  = Rendering.DataSourceItem[Templates.StaticMap.Fields.CentralPointLatitude];
            var zoom      = Zoom.ToString();
            var width     = Rendering.DataSourceItem[Templates.StaticMap.Fields.Width];
            var height    = Rendering.DataSourceItem[Templates.StaticMap.Fields.Height];
            var data      = new
            {
                mode,
                latitude,
                longitude,
                Pois,
                key,
                zoom,
                width,
                height
            };

            return(new JavaScriptSerializer().Serialize(data));
        }
コード例 #7
0
ファイル: MapService.cs プロジェクト: huaan011/BMap.NET
 /// <summary>
 /// 从缓存中加载瓦片
 /// </summary>
 /// <param name="zoom"></param>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <param name="map_mode"></param>
 /// <returns></returns>
 private Bitmap TileFromCache(int zoom, int x, int y, MapMode map_mode)
 {
     try
     {
         string cache_path = Properties.BMap.Default.MapCachePath;
         if (Directory.Exists(cache_path + "\\" + map_mode.ToString()))
         {
             string cache_name = cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp";
             if (File.Exists(cache_name))
             {
                 return new Bitmap(cache_name);
             }
             else
             {
                 return null;
             }
         }
         else
         {
             return null;
         }
     }
     catch
     {
         return null;
     }
 }
コード例 #8
0
ファイル: MapService.cs プロジェクト: huaan011/BMap.NET
        /// <summary>
        /// 将从服务器上下载的瓦片保存到缓存
        /// </summary>
        /// <param name="zoom"></param>
        /// <param name="x"></param>
        /// <param name="y"></param>
        /// <param name="map_mode"></param>
        /// <param name="tile"></param>
        private void SaveTile2Cache(int zoom, int x, int y, MapMode map_mode, Bitmap tile)
        {
            try
            {
                string cache_path = Properties.BMap.Default.MapCachePath;
                if (!Directory.Exists(cache_path + "\\" + map_mode.ToString()))
                {
                    Directory.CreateDirectory(cache_path + "\\" + map_mode.ToString());
                }
                tile.Save(cache_path + "\\" + map_mode.ToString() + "\\" + zoom + "_" + x + "_" + y + ".bmp");
            }
            catch
            {

            }
        }