国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > .NET > 正文

在WinForm和WPF中使用GMap.Net地圖插件簡單教程

2024-07-10 12:44:10
字體:
來源:轉載
供稿:網友

如何在WinForm中使用GMap.Net

項目主頁:https://greatmaps.codeplex.com/

下載GMap.Net,我下載的版本:greatmaps_81b71bf30091,編譯三個核心項目:

GMap.Net.Core:核心DLL

GMap.Net.WindowsForms:WinForm中使用的DLL

GMap.NET.WindowsPresentation:WPF中使用的DLL

在WinForm項目中使用GMap:

1、新建一個Visual C# 的Windows窗口程序。添加對GMap.Net.Core.DLL和GMap.Net.WindowsForms.DLL的引用。

2、在項目中添加一個UserControl,這里取名為MapControl,修改這個UserControl,使其繼承于GMapControl,這就是展示地圖的控件。修改如下:

代碼如下:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using GMap.NET.WindowsForms;

namespace GMapWinFormDemo
{
    public partial class MapControl : GMapControl
    {
        public MapControl()
        {
            InitializeComponent();
        }
    }
}

3、編譯項目,在我們的Form設計窗口下,在工具箱中(tool box)里就可以看到這個MapControl,將這個MapControl加到Form中。

4、在主Form中添加相關的代碼如下:

代碼如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using GMap.NET;
using GMap.NET.MapProviders;
using GMap.NET.WindowsPresentation;

namespace GMapWPFDemo
{
    /// <summary>
    /// MainWindow.xaml 的交互邏輯
    /// </summary>
    public partial class MainWindow : Window
    {
        public MainWindow()
        {
            InitializeComponent();

            try
            {
                System.Net.IPHostEntry e = System.Net.Dns.GetHostEntry("www.google.com.hk");
            }
            catch
            {

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 灵台县| 新津县| 潜江市| 故城县| 金阳县| 徐水县| 青神县| 青铜峡市| 枣强县| 左云县| 朝阳市| 北宁市| 老河口市| 胶州市| 宁波市| 葫芦岛市| 衡山县| 绍兴市| 凌海市| 叶城县| 永丰县| 福海县| 宁武县| 聊城市| 韩城市| 宣化县| 昭苏县| 克山县| 浦县| 利津县| 牡丹江市| 临猗县| 嘉黎县| 长葛市| 永康市| 彭阳县| 新竹市| 青河县| 大英县| 正安县| 石首市|