using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace XGMap_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
/*
//控件安装,两种使用方法
//1、在工具箱中“添加项”,选择dll文件,即可显示控件XGMap
//2、直接在项目中添加dll引用,然后动态添加到窗体,如:
// XGMap.GMap gm = new XGMap.GMap();
// gm.Dock = DockStyle.Fill;
// this.Controls.Add(gm);
//GPRS流量产生事件
this.gMap1.OnGPRSChanged += new XGMap.GMap.OnGPRSChangedHandle(gMap1_OnGPRSChanged);
//设置地图中心点
this.Center=new X.CLatLng(...);
//设置地图放大缩小
this.Zoom=1至19
//用户输入某点显示在地图中心处(与MyPosition属性类似,但图标点样式不同)
this.gMap1.InputCenter = new X.CLatLng();
//给地图添加标记点
this.gMap1.Markers = new List<XGMap.CMarker>();
//注:如果是以下面方式添加标记点时,需要刷新地图:
this.gMap1.Markers.Add(new XGMap.CMarker());
this.gMap1.RefreshMap();
//关于类XGMap.CMarker
XGMap.CMarker mk = new XGMap.CMarker();
mk.data = null; //用户附加数据,默认为空
mk.font = null; //显示标记的字体
mk.image = null;//标记图片
mk.latlng = null;//标记经续度
mk.Text = "";//标记文本
*/
}
void gMap1_OnGPRSChanged(object sender, long count)
{
//count:网络访问时产生的流量,估算值,稍偏小
}
private void mClose_Click(object sender, EventArgs e)
{
this.Close(); Application.Exit();
}
private void mSatellite_Click(object sender, EventArgs e)
{
//改变地图类型(普通 或 卫星)
this.gMap1.Maptype = X.eMapType.satellite;
}
private void mMyPosition_Click(object sender, EventArgs e)
{
Cursor.Current = Cursors.WaitCursor;
//获取手机基站信息
X.CLacCellid laccellid = X.GPS.getLacCellid();
int gprs = 0;
//转换基站信息为经纬度
//参数NetPoint为接入点名称
X.CLatLng latlng = X.GPS.getGEOfromCellid(laccellid.lac, laccellid.cellid, "CMWAP", ref gprs);
//设定我的位置(将会显示在地图中心)
this.gMap1.MyPosition = latlng;
Cursor.Current = Cursors.Default;
}
}
}
控件Sample下载