MapControlExtensions.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using DevExpress.XtraMap;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace Ips.Library.DxpLib
  8. {
  9. public static class MapControlExtensions
  10. {
  11. public static void InitIpsOptions(this MapControl mapControl, IpsMapOption options = null)
  12. {
  13. if (options == null) options = new IpsMapOption();
  14. mapControl.CenterPoint = new GeoPoint(24.5408, 118.9236);
  15. mapControl.ZoomLevel = options.ZoomLevel;
  16. mapControl.EnableAnimation = false;
  17. mapControl.EnableRotation = false;
  18. mapControl.NavigationPanelOptions.Height = 20;
  19. mapControl.NavigationPanelOptions.BackgroundStyle.Fill = Color.Transparent;
  20. mapControl.NavigationPanelOptions.CoordinatesStyle.Font = new Font("Consolas", 9F, FontStyle.Bold, GraphicsUnit.Point, ((byte)(0)));
  21. mapControl.NavigationPanelOptions.Height = 20;
  22. mapControl.NavigationPanelOptions.ShowKilometersScale = false;
  23. mapControl.NavigationPanelOptions.ShowMilesScale = false;
  24. mapControl.NavigationPanelOptions.ShowScrollButtons = false;
  25. mapControl.NavigationPanelOptions.ShowZoomTrackbar = false;
  26. mapControl.NavigationPanelOptions.XCoordinatePattern = "{D:3}°{CP}";
  27. mapControl.NavigationPanelOptions.YCoordinatePattern = "{D:3}°{CP}";
  28. mapControl.NavigationPanelOptions.CoordinatesStyle.TextColor = System.Drawing.Color.Black;
  29. (mapControl.CoordinateSystem as GeoMapCoordinateSystem).CircularScrollingMode = options.CircularScrollingMode;
  30. mapControl.Layers.Insert(0, CreateImageLayer(MapConsts.NormalMapNum));
  31. }
  32. public static ImageLayer CreateImageLayer(int maptype)
  33. {
  34. var imageLayer = new ImageLayer();
  35. ImageTileDataProvider tileDataProvider = new ImageTileDataProvider();
  36. var tileSource = new SqliteTileGenerator();
  37. tileSource.MapType = maptype;
  38. tileDataProvider.TileSource = tileSource;
  39. imageLayer.DataProvider = tileDataProvider;
  40. return imageLayer;
  41. }
  42. }
  43. public class IpsMapOption
  44. {
  45. public double ZoomLevel { get; set; } = 3d;
  46. public CircularScrollingMode CircularScrollingMode { get; set; } = CircularScrollingMode.TilesAndVectorItems;
  47. }
  48. }