zoukankan      html  css  js  c++  java
  • (转)深入理解最强桌面地图控件GMAP.NET --- 初用

    上一篇介绍了GMAP.NET的基本概念和一些Demo的截图,这一章主要介绍我们的代码如何使用GMAP.NET。

    1.下载

    http://greatmaps.codeplex.com/releases/view/20235

    2.编译GMAP.NET工程

    3.在项目中引用

    我的项目是用的WPF,因此需要引用GMAP.NET Core和GMap.NET.WindowsPresentation两个dll。

    4.GMapControl

     1)UserControl.xaml 创建一个UserControl,并在UserControl中引用GMapControl,我设置了MaxZoom和MinZoom, 也是GMAP.NET支持的最大缩放比例尺,如下所示:

    复制代码
    <UserControl x:Class="UICommon.View.Map.GMapTrack"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:gmap="clr-namespace:GMap.NET.WindowsPresentation;assembly=GMap.NET.WindowsPresentation"
                 xmlns:Map="clr-namespace:UICommon.View.Map" x:Name="userControl"
        >
        <Grid>
          
            <GroupBox Name="mapgroup" Margin="0,0,50,0"  VerticalContentAlignment="Stretch" HorizontalContentAlignment="Stretch">
                <gmap:GMapControl x:Name="MainMap"  MaxZoom="24" MinZoom="1">
                  
                </gmap:GMapControl>
            </GroupBox>   
            
        </Grid>
    </UserControl>
    复制代码

    5.GMapControl事件

    设置事件代码,包括鼠标进入事件MouseEnter, 鼠标右键事件MouseRightButtonDown,鼠标双击事件MouseDoubleClick。

    OnTileLoadStart和OnTileLoadComplete这两个事件是这样的:所有地图下载的时候都是讲一张一张图片下载下来拼接而成的,而这里的图片就叫做Tile。所以

    OnTileLoadStart就是指每次每张图片开始载入时触发的事件,OnTileLoadComplete就是每次每张图片载入完成后触发的事件。那么就可以在OnTileLoadStart的时候显示

    正在加载或进度条之类的,不会让用户感觉死在那儿;而OnTileLoadComplete可以关闭进度条。

    复制代码
    public GMapTrack()
            {
                InitializeComponent();
    
                this.MainMap.MouseEnter += MainMap_MouseEnter;
            this.MainMap.MouseRightButtonDown += new MouseButtonEventHandler(MainMap_MouseRightButtonDown);
                this.MainMap.MouseDoubleClick += new MouseButtonEventHandler(MainMap_MouseDoubleClick);
           this.MainMap.OnTileLoadStart += MainMap_OnTileLoadStart;
    this.MainMap.OnTileLoadComplete += MainMap_OnTileLoadComplete;
    this.MainMap.Loaded += new RoutedEventHandler(MainMap_Loaded);
    }
    复制代码

    6.GMapControl Loaded初始化

    Position是地图默认启动的中心位置,我这里是从配置文件里面读取的。

    Area是指整个地图的区域,可以不填

    Mode有三种, CacheOnly(只从缓存中取),ServerAndCache(网络+缓存), ServerOnly(只从网络读)

    MapProvider是地图的来源,默认是OpenStreetMap,当然也可以使BingMap, GoogleMap,关于百度,SoSo等国内地图的支持会在后面的章节介绍。

    DragButton是指拖动地图时是用鼠标左键还是右键

    Zoom是当前地图显示的层级 (1~24)

    MinZoom是地图支持最小的层级,MaxZoom是地图支持的最大层级。

    复制代码
                    this.MainMap.Position = new PointLatLng(double.Parse(ConfigurationManager.AppSettings["defaultLat"]), 
                                                            double.Parse(ConfigurationManager.AppSettings["defaultLng"]));
    
                    this.MainMap.MapProvider.Area = new RectLatLng(30.981178, 105.351914, 2.765142, 4.120995);
                    this.MainMap.BoundsOfMap = new RectLatLng(30.981178, 105.351914,  2.765142, 4.120995);
                    this.MainMap.Manager.Mode = AccessMode.CacheOnly;
                    this.MainMap.MapProvider = GMapProviders.OpenStreetMap;
                    this.MainMap.DragButton = MouseButton.Left;
                    this.MainMap.Zoom = 13;
                    this.MainMap.MinZoom = 8;
                    this.MainMap.MaxZoom = 24;
    复制代码

     原文链接:http://www.cnblogs.com/enjoyeclipse/archive/2013/01/13/2858590.html

  • 相关阅读:
    实例属性 类属性 实例域 类域
    研究数据集
    static 静态域 类域 静态方法 工厂方法 he use of the static keyword to create fields and methods that belong to the class, rather than to an instance of the class 非访问修饰符
    accessor mothod mutator mothod 更改器方法 访问器方法 类的方法可以访问类的任何一个对象的私有域!
    上钻 下钻 切片 转轴 降采样
    识别会话
    Performance Tuning Using Linux Process Management Commands
    Secure Hash Algorithm 3
    grouped differently across partitions
    spark 划分stage Wide vs Narrow Dependencies 窄依赖 宽依赖 解析 作业 job stage 阶段 RDD有向无环图拆分 任务 Task 网络传输和计算开销 任务集 taskset
  • 原文地址:https://www.cnblogs.com/plRobotics-RD-Center/p/4008895.html
Copyright © 2011-2022 走看看